【问题标题】:How can I change Ruby to version 1.9.3 (again) with RVM?如何使用 RVM 将 Ruby 更改为 1.9.3 版(再次)?
【发布时间】:2012-11-05 20:02:35
【问题描述】:

我曾经在 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.

【问题讨论】:

  • 感谢@mabako,我已经看过了,还有更多。情况不同

标签: ruby-on-rails ruby rvm


【解决方案1】:

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

/bin/bash --login

之后,您将能够使用 RVM 选择 Ruby。

此外,还有一种永久的方式,即您不必每次打开终端时都编写此行。 试试这个:

Edit menu -> Profile Preferences 

会出现一个对话框,现在选择Run command in login shell

之后,无论何时打开终端,都会进入登录shell,就可以使用RVM了。

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

【讨论】:

  • 配置文件首选项正确,并且选择了“在登录 shell 中运行命令”,因为我之前这样做过
  • 这对你没有用吗?实际上我得到了同样的错误,并得到了解决。现在 rvm 运行良好。
  • "/bin/bash --login in your .bash_profile" -- 我认为这行不通,因为 .bash_profile 仅在您处于登录 shell 时运行...另外,它当您启动登录 shell 时,会无限循环启动 bash!
猜你喜欢
  • 1970-01-01
  • 2012-01-29
  • 1970-01-01
  • 1970-01-01
  • 2012-02-22
  • 2012-07-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多