开发者

"gem install" requires Ruby version >= 1.8.7, which is installed

$ gem -v
1.8.5
$ ruby -v
ruby 1.8.7 (2010-04-19 patchlevel 253) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2010.02

$ sudo gem install sanitize
ERROR:  Error installing sanitize:
    nokogiri requires Ruby version >= 1.8.7

This happens for other gems as well, not just nokogiri. I am on Ruby 1.8.7 and have set my $PATH to include /opt/ruby-enter开发者_开发问答prise-1.8.7-2010.02/bin/ruby before /usr/bin where system Ruby (1.8.6) is installed.

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.5
  - RUBY VERSION: 1.8.7 (2010-04-19 patchlevel 253) [x86_64-linux]
  - INSTALLATION DIRECTORY: /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby
  - EXECUTABLE DIRECTORY: /opt/ruby-enterprise-1.8.7-2010.02/bin

$ which ruby
/opt/ruby-enterprise-1.8.7-2010.02/bin/ruby
$which gem
/opt/ruby-enterprise-1.8.7-2010.02/bin/gem


Your sudo command is most probably changing your PATH variable. Try sudo gem env and you can verify this. As a solution you might try this:

sudo env PATH=$PATH gem install ...

Also see here for further discussion:
sudo changes PATH - why?

As a workaround you could also do:

sudo su -m

To get to a root prompt using the -m modifier to preserve environment. Then from that root prompt do your gem installs.


Well your sudo command looks fine (i.e., no dash there so it should be reusing your environment), but you could try sudo which gem just to be sure. It sometimes depends on the version of Unix/Linux.

I tracked something like this down once upon a time. My path (and yours) was correct, but there was something internal to gem that either ignored the path or was looking for "standard" directories first and thus finding the older version of ruby.

My solution was to uninstall the old version. Not the most elegant but I didn't need the old version anyway.

Good luck, I hope you're in a position to uninstall the old version.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜