I am using Debian Squeeze as my OS and am trying to develop a Ruby on Rails projects. For that I first installed some ruby packages.
我正在使用Debian Squeeze作为我的操作系统,并且正在尝试开发Ruby on Rails项目。为此,我首先安装了一些ruby包。
My ruby versions are: ruby1.8, ruby1.9.1
我的ruby版本是:ruby1.8,ruby1.9.1
Then I uninstalled ruby1.8 to make ruby1.9.1 my default ruby.
然后我卸载ruby1.8使ruby1.9.1成为我的默认ruby。
Now if I run:
现在,如果我跑:
$ which ruby
it displays nothing.
它什么也没显示。
If I run:
如果我跑:
$ which ruby1.9.1
/usr/bin/ruby1.9.1
However:
然而:
$ rails new testApp
bash: /usr/bin/rails: /usr/bin/ruby1.8: bad interpreter: No such file or directory
I don't know what to do. Please guide me.
我不知道该怎么办。请指导我。
3 个解决方案
#1
12
For Debian squeeze (6.0):
对于Debian squeeze(6.0):
First make sure to uninstall all ruby and ruby1.8 packages. Otherwise they will interfere with the binaries/links that are about to be set up for ruby 1.9.
首先确保卸载所有ruby和ruby1.8软件包。否则,它们将干扰即将为ruby 1.9设置的二进制文件/链接。
Then install the ruby 1.9 packages. Despite the fact that these packages are named '1.9.1' they actually install ruby version 1.9.2 on Debian squeeze. The virtual package ruby1.9.1-full
will install all the packages necessary for ruby:
然后安装ruby 1.9软件包。尽管这些软件包名为“1.9.1”,但它们实际上是在Debian squeeze上安装了ruby版本1.9.2。虚拟包ruby1.9.1-full将安装ruby所需的所有包:
sudo aptitude install ruby1.9.1-full
Add alternative links for ri and manpage in the ri1.9.1 package. (These two lines are all one command.)
在ri1.9.1包中为ri和manpage添加备用链接。 (这两行都是一个命令。)
sudo update-alternatives --install /usr/bin/ri ri /usr/bin/ri1.9.1 10 \
--slave /usr/share/man/man1/ri.1.gz ri.1.gz /usr/share/man/man1/ri1.9.1.1.gz
Add alternative links for ruby, associated binaries, and manpages in the ruby1.9.1 package. (These lines are all one command.)
在ruby1.9.1包中添加ruby,关联二进制文件和联机帮助页的备用链接。 (这些行都是一个命令。)
sudo update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 10 \
--slave /usr/share/man/man1/ruby.1.gz ruby.1.gz /usr/share/man/man1/ruby1.9.1.1.gz \
--slave /usr/bin/erb erb /usr/bin/erb1.9.1 \
--slave /usr/bin/gem gem /usr/bin/gem1.9.1 \
--slave /usr/bin/irb irb /usr/bin/irb1.9.1 \
--slave /usr/bin/rake rake /usr/bin/rake1.9.1 \
--slave /usr/bin/rdoc rdoc /usr/bin/rdoc1.9.1 \
--slave /usr/bin/testrb testrb /usr/bin/testrb1.9.1 \
--slave /usr/share/man/man1/erb.1.gz erb.1.gz /usr/share/man/man1/erb1.9.1.1.gz \
--slave /usr/share/man/man1/gem.1.gz gem.1.gz /usr/share/man/man1/gem1.9.1.1.gz \
--slave /usr/share/man/man1/irb.1.gz irb.1.gz /usr/share/man/man1/irb1.9.1.1.gz \
--slave /usr/share/man/man1/rake.1.gz rake.1.gz /usr/share/man/man1/rake1.9.1.1.gz \
--slave /usr/share/man/man1/rdoc.1.gz rdoc.1.gz /usr/share/man/man1/rdoc1.9.1.1.gz \
--slave /usr/share/man/man1/testrb.1.gz testrb.1.gz /usr/share/man/man1/testrb1.9.1.1.gz
Note that these are all installed at a low alternative priority of 10 (the last portion after the --install
flag but before the --slave
flags). This is done in the hope that future versions of Debian will include both ruby 1.8 and ruby 1.9 as part of the alternatives system and override these links.
请注意,这些都是以10的低替代优先级安装的(在--install标志之后但在--slave标志之前的最后一部分)。这样做是为了希望Debian的未来版本将包括ruby 1.8和ruby 1.9作为替代系统的一部分并覆盖这些链接。
Check ri in the alternatives system:
检查替代系统中的ri:
update-alternatives --display ri
The result:
结果:
ri - auto mode
link currently points to /usr/bin/ri1.9.1
/usr/bin/ri1.9.1 - priority 10
slave ri.1.gz: /usr/share/man/man1/ri1.9.1.1.gz
Current 'best' version is '/usr/bin/ri1.9.1'.
Check ruby in the alternatives system:
检查替代系统中的ruby:
update-alternatives --display ruby
The result:
结果:
ruby - auto mode
link currently points to /usr/bin/ruby1.9.1
/usr/bin/ruby1.9.1 - priority 10
slave erb: /usr/bin/erb1.9.1
slave erb.1.gz: /usr/share/man/man1/erb1.9.1.1.gz
slave gem: /usr/bin/gem1.9.1
slave gem.1.gz: /usr/share/man/man1/gem1.9.1.1.gz
slave irb: /usr/bin/irb1.9.1
slave irb.1.gz: /usr/share/man/man1/irb1.9.1.1.gz
slave rake: /usr/bin/rake1.9.1
slave rake.1.gz: /usr/share/man/man1/rake1.9.1.1.gz
slave rdoc: /usr/bin/rdoc1.9.1
slave rdoc.1.gz: /usr/share/man/man1/rdoc1.9.1.1.gz
slave ruby.1.gz: /usr/share/man/man1/ruby1.9.1.1.gz
slave testrb: /usr/bin/testrb1.9.1
slave testrb.1.gz: /usr/share/man/man1/testrb1.9.1.1.gz
Current 'best' version is '/usr/bin/ruby1.9.1'.
#2
9
What I do on my squeeze boxes to get ruby 1.9 as default:
我在挤压盒上做的是默认情况下获得ruby 1.9:
cd /usr/bin
ln -sf ruby1.9.1 ruby
ln -sf gem1.9.1 gem
ln -sf erb1.9.1 erb
ln -sf irb1.9.1 irb
ln -sf rake1.9.1 rake
ln -sf rdoc1.9.1 rdoc
ln -sf testrb1.9.1 testrb
I run a lot of rails production servers this way and all other debian ruby packages are not broken because they relay on /usr/bin/ruby1.8 binary.
我以这种方式运行了很多rails生产服务器,并且所有其他debian ruby软件包都没有被破坏,因为它们在/usr/bin/ruby1.8二进制文件上进行中继。
This not "true debian way" but for some reason update-alternatives
does not support configuring ruby in squeeze.
这不是“真正的debian方式”,但由于某种原因,更新替代方案不支持在挤压中配置ruby。
In Ubuntu 11.10 you can just run update-alternatives --config ruby
and selected desired version
在Ubuntu 11.10中,您可以运行update-alternatives --config ruby并选择所需的版本
I also recommend you to update rubygems before you start installing any gems REALLY_GEM_UPDATE_SYSTEM=true gem update --system
我还建议你在开始安装任何宝石之前更新rubygems REALLY_GEM_UPDATE_SYSTEM = true gem update --system
#3
1
although I don't have the direct answer of your question, I suggest you try with the wonderful rvm(ruby version manager) tool( http://beginrescueend.com/ ). It make my life a lot easier when I try to play with ruby on Ubuntu.
虽然我没有直接回答你的问题,但我建议你试试精彩的rvm(ruby版本管理器)工具(http://beginrescueend.com/)。当我尝试在Ubuntu上使用ruby时,它让我的生活变得更轻松。
#1
12
For Debian squeeze (6.0):
对于Debian squeeze(6.0):
First make sure to uninstall all ruby and ruby1.8 packages. Otherwise they will interfere with the binaries/links that are about to be set up for ruby 1.9.
首先确保卸载所有ruby和ruby1.8软件包。否则,它们将干扰即将为ruby 1.9设置的二进制文件/链接。
Then install the ruby 1.9 packages. Despite the fact that these packages are named '1.9.1' they actually install ruby version 1.9.2 on Debian squeeze. The virtual package ruby1.9.1-full
will install all the packages necessary for ruby:
然后安装ruby 1.9软件包。尽管这些软件包名为“1.9.1”,但它们实际上是在Debian squeeze上安装了ruby版本1.9.2。虚拟包ruby1.9.1-full将安装ruby所需的所有包:
sudo aptitude install ruby1.9.1-full
Add alternative links for ri and manpage in the ri1.9.1 package. (These two lines are all one command.)
在ri1.9.1包中为ri和manpage添加备用链接。 (这两行都是一个命令。)
sudo update-alternatives --install /usr/bin/ri ri /usr/bin/ri1.9.1 10 \
--slave /usr/share/man/man1/ri.1.gz ri.1.gz /usr/share/man/man1/ri1.9.1.1.gz
Add alternative links for ruby, associated binaries, and manpages in the ruby1.9.1 package. (These lines are all one command.)
在ruby1.9.1包中添加ruby,关联二进制文件和联机帮助页的备用链接。 (这些行都是一个命令。)
sudo update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 10 \
--slave /usr/share/man/man1/ruby.1.gz ruby.1.gz /usr/share/man/man1/ruby1.9.1.1.gz \
--slave /usr/bin/erb erb /usr/bin/erb1.9.1 \
--slave /usr/bin/gem gem /usr/bin/gem1.9.1 \
--slave /usr/bin/irb irb /usr/bin/irb1.9.1 \
--slave /usr/bin/rake rake /usr/bin/rake1.9.1 \
--slave /usr/bin/rdoc rdoc /usr/bin/rdoc1.9.1 \
--slave /usr/bin/testrb testrb /usr/bin/testrb1.9.1 \
--slave /usr/share/man/man1/erb.1.gz erb.1.gz /usr/share/man/man1/erb1.9.1.1.gz \
--slave /usr/share/man/man1/gem.1.gz gem.1.gz /usr/share/man/man1/gem1.9.1.1.gz \
--slave /usr/share/man/man1/irb.1.gz irb.1.gz /usr/share/man/man1/irb1.9.1.1.gz \
--slave /usr/share/man/man1/rake.1.gz rake.1.gz /usr/share/man/man1/rake1.9.1.1.gz \
--slave /usr/share/man/man1/rdoc.1.gz rdoc.1.gz /usr/share/man/man1/rdoc1.9.1.1.gz \
--slave /usr/share/man/man1/testrb.1.gz testrb.1.gz /usr/share/man/man1/testrb1.9.1.1.gz
Note that these are all installed at a low alternative priority of 10 (the last portion after the --install
flag but before the --slave
flags). This is done in the hope that future versions of Debian will include both ruby 1.8 and ruby 1.9 as part of the alternatives system and override these links.
请注意,这些都是以10的低替代优先级安装的(在--install标志之后但在--slave标志之前的最后一部分)。这样做是为了希望Debian的未来版本将包括ruby 1.8和ruby 1.9作为替代系统的一部分并覆盖这些链接。
Check ri in the alternatives system:
检查替代系统中的ri:
update-alternatives --display ri
The result:
结果:
ri - auto mode
link currently points to /usr/bin/ri1.9.1
/usr/bin/ri1.9.1 - priority 10
slave ri.1.gz: /usr/share/man/man1/ri1.9.1.1.gz
Current 'best' version is '/usr/bin/ri1.9.1'.
Check ruby in the alternatives system:
检查替代系统中的ruby:
update-alternatives --display ruby
The result:
结果:
ruby - auto mode
link currently points to /usr/bin/ruby1.9.1
/usr/bin/ruby1.9.1 - priority 10
slave erb: /usr/bin/erb1.9.1
slave erb.1.gz: /usr/share/man/man1/erb1.9.1.1.gz
slave gem: /usr/bin/gem1.9.1
slave gem.1.gz: /usr/share/man/man1/gem1.9.1.1.gz
slave irb: /usr/bin/irb1.9.1
slave irb.1.gz: /usr/share/man/man1/irb1.9.1.1.gz
slave rake: /usr/bin/rake1.9.1
slave rake.1.gz: /usr/share/man/man1/rake1.9.1.1.gz
slave rdoc: /usr/bin/rdoc1.9.1
slave rdoc.1.gz: /usr/share/man/man1/rdoc1.9.1.1.gz
slave ruby.1.gz: /usr/share/man/man1/ruby1.9.1.1.gz
slave testrb: /usr/bin/testrb1.9.1
slave testrb.1.gz: /usr/share/man/man1/testrb1.9.1.1.gz
Current 'best' version is '/usr/bin/ruby1.9.1'.
#2
9
What I do on my squeeze boxes to get ruby 1.9 as default:
我在挤压盒上做的是默认情况下获得ruby 1.9:
cd /usr/bin
ln -sf ruby1.9.1 ruby
ln -sf gem1.9.1 gem
ln -sf erb1.9.1 erb
ln -sf irb1.9.1 irb
ln -sf rake1.9.1 rake
ln -sf rdoc1.9.1 rdoc
ln -sf testrb1.9.1 testrb
I run a lot of rails production servers this way and all other debian ruby packages are not broken because they relay on /usr/bin/ruby1.8 binary.
我以这种方式运行了很多rails生产服务器,并且所有其他debian ruby软件包都没有被破坏,因为它们在/usr/bin/ruby1.8二进制文件上进行中继。
This not "true debian way" but for some reason update-alternatives
does not support configuring ruby in squeeze.
这不是“真正的debian方式”,但由于某种原因,更新替代方案不支持在挤压中配置ruby。
In Ubuntu 11.10 you can just run update-alternatives --config ruby
and selected desired version
在Ubuntu 11.10中,您可以运行update-alternatives --config ruby并选择所需的版本
I also recommend you to update rubygems before you start installing any gems REALLY_GEM_UPDATE_SYSTEM=true gem update --system
我还建议你在开始安装任何宝石之前更新rubygems REALLY_GEM_UPDATE_SYSTEM = true gem update --system
#3
1
although I don't have the direct answer of your question, I suggest you try with the wonderful rvm(ruby version manager) tool( http://beginrescueend.com/ ). It make my life a lot easier when I try to play with ruby on Ubuntu.
虽然我没有直接回答你的问题,但我建议你试试精彩的rvm(ruby版本管理器)工具(http://beginrescueend.com/)。当我尝试在Ubuntu上使用ruby时,它让我的生活变得更轻松。