使用apt-get install ruby 2.0.0成功安装了ruby,但是没有使用正确的ruby版本 [英] installed ruby using apt-get install ruby 2.0.0 succeeded but not using correct ruby version
问题描述
我真的是Linux新手.我目前正在数字海洋上部署应用程序,因此我暂时切换到linux ox.
Hi I am really new to linux. I am currently deploying an app on digital ocean so I am switching to linux ox temporarily.
我做了
sudo apt-get install ruby 2.0.0
并正确安装,但是当我执行ruby-v时,我得到的是1.8.7版本.
and installed correctly but when I do ruby-v I am getting the 1.8.7 version.
我确定旧版本已经预先包装了薄荷糖.
I am sure that the old version is prepackaged with mint.
如何在bash配置文件或linux启动文件中切换到ruby 2.0.0?
How do I switch to ruby 2.0.0 in my bash profile or the linux startup files?
推荐答案
如果您是Linux的新手,我建议您使用RVM(Ruby版本管理器)之类的工具来安装ruby.它使切换红宝石版本和管理多个宝石集变得更加容易.
If you're new to linux I'd recommend using something like RVM (Ruby Version Manager) to install ruby. It makes it easier to switch ruby versions and manage multiple gemsets.
要使用最新(稳定)的ruby安装RVM:
To install RVM with the latest (stable) ruby:
\curl -L https://get.rvm.io | bash -s stable --ruby
然后检查使用安装了哪些红宝石
then check which rubies are installed by using
rvm list
然后您可以使用切换红宝石版本
you can then switch ruby versions using
rvm use 2.0.0 --default
带有--default
标志的
会覆盖所有系统红宝石.
with the --default
flag overriding any system ruby.
更新
如果您真的不想使用RVM,请使用
Update
If you really don't want to use RVM, then use
sudo apt-get install checkinstall
wget -c http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
tar -xzf ruby-2.0.0-p0.tar.gz
cd ruby-2.0.0-p0
./configure
make
sudo checkinstall -y \
--pkgversion 2.0.0-p0 \
--provides "ruby-interpreter"
checkinstall
将打包源,使将来更容易删除
checkinstall
will package the source, making it easier to remove in the future
然后,您需要通过编辑env文件将Ruby二进制文件添加到您的路径中:
You'll then need to add the Ruby binaries to your path, by editing the env file:
sudo nano /etc/environment
添加/usr/local/ruby/bin
add /usr/local/ruby/bin
PATH="/usr/local/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
然后运行
source /etc/environment
重新加载文件,并使用
ruby -v
这篇关于使用apt-get install ruby 2.0.0成功安装了ruby,但是没有使用正确的ruby版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!