尝试重新安装Ruby但RubyGem无法安装

时间:2013-08-02 21:25:11

标签: ruby-on-rails ruby

Mac OSX用户Ruby on Rails的新用户。我试图重新安装Ruby 2.0.0,因为RubyGem存在一些问题,导致我无法安装Rails。在重新安装结束时,我收到一条错误消息,指出RubyGem无法安装:

Removing /Users/yuanhunglo/.rvm/src/ruby-2.0.0-p0...
Removing /Users/yuanhunglo/.rvm/rubies/ruby-2.0.0-p0...
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.8/x86_64/ruby-2.0.0-p0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Installing requirements for osx, might require sudo password.
Certificates in '/Users/yuanhunglo/.rvm/etc/openssl/cert.pem' already are up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/yuanhunglo/.rvm/rubies/ruby-2.0.0-p0, this may take a while depending on your cpu(s)...
ruby-2.0.0-p0 - #downloading ruby-2.0.0-p0, this may take a while depending on your connection...
ruby-2.0.0-p0 - #extracting ruby-2.0.0-p0 to /Users/yuanhunglo/.rvm/src/ruby-2.0.0-p0
ruby-2.0.0-p0 - #extracted to /Users/yuanhunglo/.rvm/src/ruby-2.0.0-p0
ruby-2.0.0-p0 - #configuring..................
ruby-2.0.0-p0 - #compiling.....
ruby-2.0.0-p0 - #installing ...................................................
Retrieving rubygems-2.0.6
Extracting rubygems-2.0.6 ...
Removing old Rubygems files...
Installing rubygems-2.0.6 for ruby-2.0.0-p0................................................
Error running 'env GEM_PATH=/Users/yuanhunglo/.rvm/gems/ruby-2.0.0-p0:/Users/yuanhunglo/.rvm/gems/ruby-2.0.0-p0@global:/Users/yuanhunglo/.rvm/gems/ruby-2.0.0-p0:/Users/yuanhunglo/.rvm/gems/ruby-2.0.0-p0@global GEM_HOME=/Users/yuanhunglo/.rvm/gems/ruby-2.0.0-p0 /Users/yuanhunglo/.rvm/rubies/ruby-2.0.0-p0/bin/ruby -d /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/setup.rb',
please read /Users/yuanhunglo/.rvm/log/ruby-2.0.0-p0/1375477539_rubygems.install.log
Installation of rubygems did not complete successfully.
Saving wrappers to '/Users/yuanhunglo/.rvm/wrappers/ruby-2.0.0-p0'...........

ruby-2.0.0-p0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-2.0.0-p0 - #importing default gemsets, this may take time...............................
Install of ruby-2.0.0-p0 - #complete 
Making gemset ruby-2.0.0-p0 pristine................................................................................................................................................................................................................
Error running '__rvm_with ruby-2.0.0-p0 /Users/yuanhunglo/.rvm/scripts/gemsets pristine',
please read /Users/yuanhunglo/.rvm/log/ruby-2.0.0-p0/1375477541_gemset.pristine-ruby-2.0.0-p0.log
Making gemset ruby-2.0.0-p0@global pristine.................................................................................................................................................................................................................
Error running '__rvm_with ruby-2.0.0-p0@global /Users/yuanhunglo/.rvm/scripts/gemsets pristine',
please read /Users/yuanhunglo/.rvm/log/ruby-2.0.0-p0/1375477543_gemset.pristine-ruby-2.0.0-p0@global.log
/Users/yuanhunglo/.rvm/src/ruby-2.0.0-p247 has already been removed.
Removing /Users/yuanhunglo/.rvm/rubies/ruby-2.0.0-p247...
Searching for binary rubies, this might take some time.
Installing requirements for osx, might require sudo password.
Certificates in '/Users/yuanhunglo/.rvm/etc/openssl/cert.pem' already are up to date.
Requirements installation successful.
ruby-2.0.0-p247 - #configure
ruby-2.0.0-p247 - #download
ruby-2.0.0-p247 - #validate archive
ruby-2.0.0-p247 - #extract
ruby-2.0.0-p247 - #validate binary
ruby-2.0.0-p247 - #setup
Saving wrappers to '/Users/yuanhunglo/.rvm/wrappers/ruby-2.0.0-p247'...........
ruby-2.0.0-p247 - #importing default gemsets, this may take time.......................
Making gemset ruby-2.0.0-p247 pristine....
Making gemset ruby-2.0.0-p247@global pristine....
Making gemset ruby-2.0.0-p247@railstutorial_rails_4_0 pristine....

我不确定是否需要安装或修改某些内容。

这是install.log

[2013-08-02 14:05:39] /Users/yuanhunglo/.rvm/rubies/ruby-2.0.0-p0/bin/ruby
Exception `LoadError' at /Users/yuanhunglo/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rubygems.rb:1073 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /Users/yuanhunglo/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rubygems.rb:1082 - cannot load such file -- rubygems/defaults/ruby
Error loading RubyGems plugin "/Users/yuanhunglo/.rvm/gems/ruby-2.0.0-p0@global/gems/rubygems-bundler-1.1.1/lib/rubygems_plugin.rb": cannot load such file -- openssl (LoadError)
/Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security.rb:355: warning: already initialized constant Gem::Security::DIGEST_ALGORITHM
/Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security.rb:355: warning: previous definition of DIGEST_ALGORITHM was here
/Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security.rb:360: warning: already initialized constant Gem::Security::DIGEST_NAME
/Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security.rb:360: warning: previous definition of DIGEST_NAME was here
/Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security.rb:365: warning: already initialized constant Gem::Security::KEY_ALGORITHM
/Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security.rb:365: warning: previous definition of KEY_ALGORITHM was here
/Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security.rb:370: warning: already initialized constant Gem::Security::KEY_LENGTH
/Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security.rb:370: warning: previous definition of KEY_LENGTH was here
/Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security.rb:375: warning: already initialized constant Gem::Security::ONE_YEAR
/Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security.rb:375: warning: previous definition of ONE_YEAR was here
/Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security.rb:385: warning: already initialized constant Gem::Security::EXTENSIONS
/Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security.rb:385: warning: previous definition of EXTENSIONS was here
/Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/core_ext/kernel_require.rb:51:in `require': cannot load such file -- openssl (LoadError)
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security/policy.rb:23:in `initialize'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security/policies.rb:6:in `new'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security/policies.rb:6:in `<module:Security>'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security/policies.rb:1:in `<top (required)>'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/security.rb:583:in `<top (required)>'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/package.rb:43:in `<top (required)>'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/installer.rb:8:in `<top (required)>'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/request_set.rb:5:in `<top (required)>'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems.rb:200:in `finish_resolve'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/rdoc.rb:14:in `<top (required)>'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/uninstaller.rb:10:in `<top (required)>'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/commands/setup_command.rb:474:in `uninstall_old_gemcutter'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/commands/setup_command.rb:146:in `execute'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/command.rb:305:in `invoke_with_build_args'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/command_manager.rb:170:in `process_args'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/command_manager.rb:130:in `run'
    from /Users/yuanhunglo/.rvm/src/rubygems-2.0.6/lib/rubygems/gem_runner.rb:60:in `run'
    from setup.rb:45:in `<main>'
RubyGems 2.0.6 installed

提前非常感谢。

1 个答案:

答案 0 :(得分:2)

请参阅此答案:RVM ruby on rails issue OpenSSL

卸载rvm,安装openssl,安装rvm


来自http://www.dinduks.com/rails-cannot-load-such-file-openssl/的说明:

  

此错误表示您的Ruby未使用openssl编译。

     

假设您使用RVM,这些是解决此问题的步骤。

     

安装openssl包

rvm pkg install openssl
  

删除您正在使用的Ruby安装

rvm remove 1.9.3
  

最后用openssl重新编译Ruby

rvm install 1.9.3 --with-openssl-dir=$HOME/.rvm/usr
  

现在一切都应该有效。别忘了:

rvm使用1.9.3 - 默认


附注:我建议安装rbenv而不是rvm。