2012-11-05 38 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