如何使用RVM将Ruby版本更改为1.9.3?

4
我曾在Ubuntu上使用Ruby版本1.9.3工作,但一次更新可能破坏了我的bash配置文件。我需要帮助把它恢复过来,而不是继续使用版本1.8.7。目前rails s打开服务器时使用的是Ruby 1.8.7,因为我在应用程序中使用了新的语法,所以会出现错误。 .bash_profile
cat ~/.bash_profile

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

which rails:

/usr/local/bin/rails

which ruby:

/usr/bin/ruby

ruby -v:

ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]

rvm list:

rvm rubies

=* ruby-1.9.3-p194 [ i686 ]

# => - current
# =* - current && default
#  * - default

rvm use 1.9.3:

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.

请查看此答案:https://dev59.com/KGoy5IYBdhLWcg3wQ78F - mabako
谢谢@mabako,我已经看过了几个。这是一个不同的情况。 - Tom
1个回答

15

您当前不在登录shell中。要进入登录shell,请尝试执行以下命令:

/bin/bash --login

接下来您将能够使用RVM选择Ruby。

另外,有一种永久的方法,使您无需每次打开终端都写这行代码。请尝试以下步骤:

Edit menu -> Profile Preferences 

一个对话框将出现,现在选择在登录shell中运行命令

之后,每当您打开终端时,您将进入登录shell,并且您将能够使用RVM。

还有另一种方法,您可以在.bash_profile中编写/bin/bash --login,这将每次重启时加载。


个人资料偏好设置正确,选择了“在登录 shell 中运行命令”,因为我之前就这样做过。 - Tom
这对你没用吗?其实我也遇到了同样的错误,但是通过这种方式解决了。现在rvm正常运行。 - Akshay Vishnoi
1
“/bin/bash --login在你的.bash_profile文件中” - 我认为这不会起作用,因为.bash_profile只在你进入登录shell时运行...此外,当你启动登录shell时,它会产生无限循环启动bash的情况! - XP84

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接