简体   繁体   中英

error installing rails on ubuntu 16.04 failed to build gem native extension

Here is the code I put in and then the error followed: I am currently figuring out rails headers and see what could be happening. I follwed this article https://gorails.com/setup/ubuntu/16.04

and this article: http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you

and nothing.

gem install rails 
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /var/lib/gems/2.3.0 directory.
rickus@rickus:~$ sudo gem install rails
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.8.1/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20170928-18941-1fdewid.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/nokogiri-1.8.1 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.1/gem_make.out

我也遇到了这个问题,我使用sudo命令安装了ruby环境管理器rvm / rbenv。您可以重新安装ruby环境管理器并避免使用sudo命令,否则所有gem安装都将需要sudo命令,应避免使用sudo命令来避免冲突未来。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM