rbenv在可用的ruby版本列表中不包括系统ruby(1.8.7)

时间:2012-06-06 02:36:28

标签: ruby ubuntu debian rbenv ubuntu-12.04

我在Ubuntu 12.04 x64桌面上使用Ruby,但是我遇到了rbenv的问题 - 它只能看到rbenv安装的ruby版本,它无法看到Ubuntu的系统ruby通过Aptitude安装:

$> rbenv versions
  1.9.2-p290
* 1.9.3-p0 (set by /home/kurtosis/bin/ruby/rbenv/version)
  jruby-1.6.5.1

1.8.7.352-2ubuntu1也应出现在该列表中。将本地或全局ruby设置为系统然后尝试运行rubyirb会导致挂起提示:

$> rbenv versions
  1.9.2-p290
* 1.9.3-p0 (set by /home/kurtosis/bin/ruby/rbenv/version)
  jruby-1.6.5.1
$> ruby --version
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
$> rbenv global system
$> rbenv versions
  1.9.2-p290
  1.9.3-p0
  jruby-1.6.5.1
$> ruby --version
^C
$> rbenv system
rbenv: no such command `system'
$>

我在安装过程中是否遗漏了某些内容,您是否已将系统ruby手动添加到rbenv或其他内容?

通过Aptitude安装Ruby 1.8.7:

$> aptitude show ruby
Package: ruby                            
State: installed
Automatically installed: no
Version: 4.8
Priority: optional
Section: interpreters
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: all
Uncompressed Size: 36.9 k
Depends: ruby1.8 (> 1.8.7.334-1)
Suggests: ri, ruby-dev
Conflicts: irb, irb, rdoc, rdoc
Replaces: irb, irb, rdoc, rdoc
Provides: irb, rdoc
Provided by: ruby1.8
Description: Transitional package for ruby1.8
 This is a transitional package which ensures that users of ruby will use ruby1.8 in the future. It can safely be removed.
Homepage: http://www.ruby-lang.org/


$> aptitude show ruby1.8
Package: ruby1.8                         
New: yes
State: installed
Automatically installed: yes
Version: 1.8.7.352-2ubuntu1
Priority: optional
Section: interpreters
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Uncompressed Size: 370 k
Depends: libc6 (>= 2.2.5), libruby1.8 (= 1.8.7.352-2ubuntu1)
Suggests: ruby1.8-examples, ri1.8
Conflicts: irb1.8 (< 1.8.7.249-3~), irb1.8 (< 1.8.7.249-3~), rdoc1.8 (< 1.8.7.249-3~), rdoc1.8 (< 1.8.7.249-3~), ri (<= 4.5), ri (<= 4.5), ri1.8 (<
           1.8.7.334-4~), ri1.8 (< 1.8.7.334-4~), ruby (<= 4.5), ruby (<= 4.5), ruby1.8
Replaces: irb1.8, irb1.8, rdoc1.8, rdoc1.8
Provides: irb1.8, rdoc1.8, ruby, ruby-interpreter
Description: Interpreter of object-oriented scripting language Ruby 1.8
 Ruby is the interpreted scripting language for quick and easy object-oriented programming.  It has many features to process text files and to do
 system management tasks (as in perl).  It is simple, straight-forward, and extensible. 

 This package provides version 1.8 series of Ruby. 

 On Debian, Ruby 1.8 is provided as separate packages.  You can get full Ruby 1.8 distribution by installing following packages. 

  ruby1.8 ruby1.8-dev ri1.8 ruby1.8-examples libtcltk-ruby1.8
Homepage: http://www.ruby-lang.org/

kurtosis@kurtosis-dm1-4050us:~/bin/projects/blogs/posterous/export$ 

路径:

$ echo $PATH
/home/kurtosis/bin/ruby/rbenv/shims:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/kurtosis/bin:/opt/apache/ant/default/bin:/opt/apache/maven/default/bin:/home/kurtosis/bin/ide/eclipse:/home/kurtosis/bin/ide/idea/default/bin:/opt/scala/bin/default/bin:/opt/typesafe-stack/bin:/home/kurtosis/bin/google/android/sdk/tools:/home/kurtosis/bin/google/android/sdk/platform-tools:/home/kurtosis/bin/google/android/ndk/default/:/opt/haskell/ghc/default/bin:/opt/haskell/platform/default/bin:/home/kurtosis/bin/ruby/rbenv/bin:/home/kurtosis/bin/node/node_modules/less/bin:/home/kurtosis/bin/google/go/bin:/home/kurtosis/bin/utilities/torrent/vuze:/home/kurtosis/bin/utilities/torrent/anomos:/home/kurtosis/bin/scripts:.

为了它的价值,我在虚拟机中使用全新安装的Ubuntu 12.04 Server x64进行测试。通过aptitude install ruby​​-full`安装ruby,然后下载并安装rbenv。同样的问题,由于某种原因它仍然无法看到系统ruby。新的PATH是:

/home/kurtosis/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/kurtosis/.rbenv/bin:.

2 个答案:

答案 0 :(得分:2)

你做什么

rbenv global system
ruby -v

rbenv local system
ruby -v

特殊版本名称系统告诉rbenv使用系统Ruby(通过搜索$ PATH检测到)。

请参阅第3.1节

https://github.com/sstephenson/rbenv

答案 1 :(得分:0)

您应该尝试使用chruby。启动shell或更改目录时,chruby不会自动切换到其他Rubies。默认情况下,chruby使用系统Ruby。

$ chruby jruby
$ chruby
   ruby-1.9.3-p327
 * jruby-1.7.0
   rubinius-2.0.0-rc1
$ which ruby
/usr/local/jruby-1.7.0/bin/ruby
$ chruby system
$ which ruby
/usr/bin/ruby