2012-11-05 39 views
4

我曾经在Ubuntu上使用Ruby 1.9.3版本,并提出了一个更新,可能会使我的bash配置文件崩溃,我需要帮助才能将其恢复,而不是使用1.8.7版本。现在rails s用Ruby 1.8.7打开服务器,由于我在我的应用中使用了更新的语法,因此我得到错误。如何使用RVM将Ruby更改为版本1.9.3(再次)?

.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. 
+0

[看这个答案](http://stackoverflow.com/questions/8663936/how-do-i-change-my-ruby-version-using-rvm) – mabako

+0

谢谢@mabako我已经看过它和几个更多。这是一种不同的情况 – Tom

回答

15

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

/bin/bash --login 

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

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

Edit menu -> Profile Preferences 

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

之后,无论何时打开终端,您都将进入登录shell,您将能够使用RVM。

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

+0

配置文件首选项是正确的,'登录shell中的运行命令'被选中,因为我之前做过 – Tom

+0

这是否适合你?其实我得到同样的错误,并得到解决。现在rvm运行良好。 –

+1

“/ bin/bash - 在你的.bash_profile中登录” - 我不认为这会起作用,因为.bash_profile只在你登录shell时运行......另外,它会启动一个无限循环bash当你启动登录shell! – XP84