rvm安装rubygems1.3.7报错问题
安装最新版本的rvm后,安装的ruby1.8.7默认安装的rubygems是2.0.14
而我原来的项目是ruby1.8.7+rubygems1.3.7+rails2.2.3环境
如果直接使用rvm安装的ruby1.8.7自带安装的rubygems2.0.14运行rails2.2.3版本项目会有异常:
/usr/local/rvm/gems/ruby-1.8.7-p374@rails223/gems/rails-2.2.3/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path': undefined method `source_index' for Gem:Module (NoMethodError)
from /usr/local/rvm/gems/ruby-1.8.7-p374@rails223/gems/rails-2.2.3/lib/initializer.rb:273:in `add_gem_load_paths'
from /usr/local/rvm/gems/ruby-1.8.7-p374@rails223/gems/rails-2.2.3/lib/initializer.rb:131:in `process'
from /usr/local/rvm/gems/ruby-1.8.7-p374@rails223/gems/rails-2.2.3/lib/initializer.rb:112:in `send'
from /usr/local/rvm/gems/ruby-1.8.7-p374@rails223/gems/rails-2.2.3/lib/initializer.rb:112:in `run'
from /var/www/html/version_1.8.7/blog/config/environment.rb:27
from /usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `gem_original_require'
from /usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `require'
from /usr/local/rvm/gems/ruby-1.8.7-p374@rails223/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
from /usr/local/rvm/gems/ruby-1.8.7-p374@rails223/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /usr/local/rvm/gems/ruby-1.8.7-p374@rails223/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
from /usr/local/rvm/gems/ruby-1.8.7-p374@rails223/gems/rails-2.2.3/lib/commands/servers/webrick.rb:59
from /usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `gem_original_require'
from /usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `require'
from /usr/local/rvm/gems/ruby-1.8.7-p374@rails223/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
from /usr/local/rvm/gems/ruby-1.8.7-p374@rails223/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /usr/local/rvm/gems/ruby-1.8.7-p374@rails223/gems/activesupport-2.2.3/lib/active_support/dependencies.rb:153:in `require'
from /usr/local/rvm/gems/ruby-1.8.7-p374@rails223/gems/rails-2.2.3/lib/commands/server.rb:49
from /usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `gem_original_require'
from /usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `require'
from script/server:3
原因:报这个异常的原因是因为新版本的rubygems2.0.14已经移除了source_index这个方法,所以会有异常
解决方法:
安装rubygems1.3.7版本
1先切换到ruby1.8.7版本
#rvm use 1.8.7-p374
2安装rubygems1.3.7
#rvm install rubygems 1.3.7 --force
(如果有异常,可以直接到相应的下载好的目录直接安装,我的就报异常了,直接执行的setup.rb文件安装的,找到你的下载的文件的位置安装就行了,我的安装
#ruby /usr/local/rvm/src/rubygems-1.3.7/setup.rb )
#-------------------------------------------------------------------------------
#说明:我执行rvm install rubygems 1.3.7 --force 报的异常为:
ruby-1.8.7-p374 - #downloading rubygems-1.3.7
ruby-1.8.7-p374 - #extracting rubygems-1.3.7.....
ruby-1.8.7-p374 - #removing old rubygems.........
ruby-1.8.7-p374 - #installing rubygems-1.3.7....
Error running 'env GEM_HOME=/usr/local/rvm/gems/ruby-1.8.7-p374@global GEM_PATH= /usr/local/rvm/rubies/ruby-1.8.7-p374/bin/ruby -d /usr/local/rvm/src/rubygems-1.3.7/setup.rb --no-document',
showing last 15 lines of /usr/local/rvm/log/1417140913_ruby-1.8.7-p374/rubygems.install.log
/usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/optparse.rb:1450:in `complete'
/usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/optparse.rb:1448:in `catch'
/usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/optparse.rb:1448:in `complete'
/usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/optparse.rb:1261:in `parse_in_order'
/usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/optparse.rb:1254:in `catch'
/usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/optparse.rb:1254:in `parse_in_order'
/usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/optparse.rb:1248:in `order!'
/usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/optparse.rb:1339:in `permute!'
/usr/local/rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/optparse.rb:1360:in `parse!'
./lib/rubygems/command.rb:340:in `handle_options'
./lib/rubygems/command.rb:263:in `invoke'
./lib/rubygems/command_manager.rb:134:in `process_args'
./lib/rubygems/command_manager.rb:104:in `run'
./lib/rubygems/gem_runner.rb:58:in `run'
/usr/local/rvm/src/rubygems-1.3.7/setup.rb:35