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.
4

1 回答 1

15

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

/bin/bash --login

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

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

Edit menu -> Profile Preferences 

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

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

还有另一种方法,您可以写入/bin/bash --login每次.bash_profile 重新启动时都会加载的内容。

于 2012-11-05T20:26:00.320 回答