Gem 求助,安装 rails 失败

yz00 · 2015年02月13日 · 最后由 yz00 回复于 2015年02月13日 · 12305 次阅读

root@yz00-Ideapad-Z460:~# gem source -r https://rubygems.org/ https://rubygems.org/ removed from sources root@yz00-Ideapad-Z460:~# gem source -l *** CURRENT SOURCES ***

root@yz00-Ideapad-Z460:~# gem source -a http://ruby.taobao.org http://ruby.taobao.org added to sources root@yz00-Ideapad-Z460:~# gem source -l *** CURRENT SOURCES ***

http://ruby.taobao.org root@yz00-Ideapad-Z460:~# gem install rails Fetching: i18n-0.7.0.gem (100%) Successfully installed i18n-0.7.0 Fetching: thread_safe-0.3.4.gem (100%) Successfully installed thread_safe-0.3.4 Fetching: tzinfo-1.2.2.gem (100%) Successfully installed tzinfo-1.2.2 Fetching: minitest-5.5.1.gem (100%) Successfully installed minitest-5.5.1 Fetching: activesupport-4.2.0.gem (100%) Successfully installed activesupport-4.2.0 Fetching: rack-1.6.0.gem (100%) Successfully installed rack-1.6.0 Fetching: rack-test-0.6.3.gem (100%) Successfully installed rack-test-0.6.3 Fetching: mini_portile-0.6.2.gem (100%) Successfully installed mini_portile-0.6.2 Fetching: nokogiri-1.6.6.2.gem (100%) Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension.

/usr/local/bin/ruby -r ./siteconf20150213-4741-m4wolb.rb extconf.rb checking if the C compiler accepts ... yes Building nokogiri using packaged libraries. *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/local/bin/ruby --help --clean --use-system-libraries /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in require': cannot load such file -- openssl (LoadError) from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:inrequire' from /usr/local/lib/ruby/2.1.0/net/https.rb:22:in <top (required)>' from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:inrequire' from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in require' from /usr/local/lib/ruby/gems/2.1.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:3:in' from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:128:in require' from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:128:inrescue in require' from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:39:in require' from extconf.rb:395:in

'

extconf failed, exit code 1

Gem files will remain installed in /usr/local/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.6.2 for inspection. Results logged to /usr/local/lib/ruby/gems/2.1.0/extensions/x86-linux/2.1.0-static/nokogiri-1.6.6.2/gem_make.out

安装 rails 时报错,就报这个错,大家帮忙看下,万分感谢!

ruby 没有安装好,缺少了 openssl 库。

建议,先用 rvm 或者 rbenv 安装 ruby.

再安装 rails

ps: 不要用 root 用户啊。

好的,我来试试,多谢

请问下 rvm 下面的 ruby 怎么卸载?是直接~$ sudo apt-get remove ruby 这样吗?rvm 下多个版本的都要卸载怎么做?例如 ruby 2.0.0 和 ruby 2.2.0

我已經安装了 rvm,你的意思是先卸载 ruby,重新安装 openssl 库之后,再 rvm 下安装 ruby,然后$gem install rails 对吧

yz00@yz00-Ideapad-Z460:~$ rvm remove ruby-2.0.0 ruby-2.0.0-p598 - #removing src/ruby-2.0.0-p598............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... Error running 'rvm_rm_rf /home/yz00/.rvm/src/ruby-2.0.0-p598', showing last 15 lines of /home/yz00/.rvm/log/1423827418_ruby-2.0.0-p598/remove.src.log rm: cannot remove ‘/home/yz00/.rvm/src/ruby-2.0.0-p598/lib/drb/drb.rb’: Permission denied rm: cannot remove ‘/home/yz00/.rvm/src/ruby-2.0.0-p598/lib/drb/invokemethod.rb’: Permission denied rm: cannot remove ‘/home/yz00/.rvm/src/ruby-2.0.0-p598/lib/securerandom.rb’: Permission denied rm: cannot remove ‘/home/yz00/.rvm/src/ruby-2.0.0-p598/lib/prime.rb’: Permission denied rm: cannot remove ‘/home/yz00/.rvm/src/ruby-2.0.0-p598/lib/mathn.rb’: Permission denied rm: cannot remove ‘/home/yz00/.rvm/src/ruby-2.0.0-p598/lib/logger.rb’: Permission denied rm: cannot remove ‘/home/yz00/.rvm/src/ruby-2.0.0-p598/string.o’: Permission denied rm: cannot remove ‘/home/yz00/.rvm/src/ruby-2.0.0-p598/vm_insnhelper.c’: Permission denied rm: cannot remove ‘/home/yz00/.rvm/src/ruby-2.0.0-p598/libruby-static.a’: Permission denied rm: cannot remove ‘/home/yz00/.rvm/src/ruby-2.0.0-p598/st.o’: Permission denied ++ typeset ret=1 ++ rvm_debug 'rvm_rm_rf error removing target dir '\''/home/yz00/.rvm/src/ruby-2.0.0-p598'\''.' ++ (( 0 )) ++ return 0 ++ return 1

为啥会有这个错呢

@yz00 你之前用 root 用户安装的,现在切成普通用户,创建的目录没有权限。

建议重新开始:

切到 root:

rm -rf home/yz00/.rvm

切到 yz00 用户,重新安装 rvm 及 ruby.

好的,谢谢!

rm -rf /home/yz00/.rvm,少了个/,给后面的哥们提醒一下

需要 登录 后方可回复, 如果你还没有账号请 注册新账号