2013-08-20 62 views
0

我有2個版本,使用RVM紅寶石的,我想刪除我的所有的寶石在這個紅寶石version 1.8.7-p302拆卸寶石錯誤

首先我試過,但我得到了錯誤

➜ ~ gem list | cut -d" " -f1 | xargs gem uninstall -aIx 
Successfully uninstalled actionmailer-2.3.5 
Successfully uninstalled actionmailer-2.3.18 
Successfully uninstalled actionpack-2.3.5 
Successfully uninstalled actionpack-2.3.18 
Successfully uninstalled activerecord-2.3.5 
Successfully uninstalled activerecord-2.3.18 
Successfully uninstalled activeresource-2.3.5 
Successfully uninstalled activeresource-2.3.18 
Successfully uninstalled activesupport-2.3.5 
Successfully uninstalled activesupport-2.3.18 
Removing bundle 
Successfully uninstalled bundler-1.3.5 
ERROR: While executing gem ... (Gem::InstallError) 
    cannot uninstall, check `gem list -d bundler-unload` 

然後我試着這也是一個錯誤

➜ ~ gem list --no-version | xargs gem uninstall -aIx 
zsh: correct 'gem' to '.gem' [nyae]? n 
ERROR: While executing gem ... (Gem::InstallError) 
    cannot uninstall, check `gem list -d bundler` 

我Gemlist:

➜ ~ gem list                     

*** LOCAL GEMS *** 

bundler (1.3.5) 
bundler-unload (1.0.1) 
declarative_authorization (0.5.1) 
fattr (2.2.1) 
i18n (0.4.2) 
mysql (2.9.1, 2.8.1) 
rack (1.1.6, 1.0.1) 
rails (2.3.18, 2.3.5) 
rake (10.1.0, 0.8.7) 
rubygems-bundler (1.2.2) 
rush (0.6.8) 
rvm (1.11.3.8) 
session (3.1.0) 
sqlite3 (1.3.8) 

更新:

我試圖刪除紅寶石1.8.7,然後安裝它,但寶石依然存在 當我鍵入我得到這個

➜ ~ rvm gemset empty default 
Are you SURE you wish to remove the installed gems for gemset 'ruby-1.8.7-p302' (/home/dexter/.rvm/gems/ruby-1.8.7-p302)? 
(anything other than 'yes' will cancel) > yes 
➜ ~ gem list 

*** LOCAL GEMS *** 

bundler (1.3.5) 
bundler-unload (1.0.1) 
rake (10.1.0) 
rubygems-bundler (1.2.2) 
rvm (1.11.3.8) 
➜ ~ gem list --no-version | xargs gem uninstall -aIx 
zsh: correct 'gem' to '.gem' [nyae]? n 
INFO: gem "bundler" is not installed 
INFO: gem "bundler-unload" is not installed 
INFO: gem "rake" is not installed 
INFO: gem "rubygems-bundler" is not installed 
INFO: gem "rvm" is not installed 

現在我無法再次安裝導軌!

➜ ~ gem rails -v '2.3.5' 
ERROR: While executing gem ... (RuntimeError) 
    Unknown command rails 

回答

4

USING RVM

1)安裝RVM。

在其餘的步驟:

永遠不要使用sudo

2)安裝紅寶石(選擇一個版本):

$ rvm install 1.9.3 

3)確保RVM當前紅寶石是您想要爲您的應用程序使用的版本:

$ rvm list 

,如有必要:

$ rvm use 1.9.3-p194 #Sometimes you have to specify the patch number as well, e.g p194 

4)創建爲您的應用寶石:

$ rvm gemset create myapp_gemset 

5)你可以列出gemsets當前紅寶石版本:

$ rvm gemset list 

,如果需要切換到您剛剛創建的寶石組:

$ rvm gemset use myapp_gemset 

6)安裝導軌寶石:

$ gem install rails --version 4.0.0 

該命令將在創業板安裝到當前的寶石。您可以檢查版本:

$ rails -v 

有一個快捷鍵,你可以用它來選擇紅寶石版本和以前的那紅寶石版本創建的寶石:

$ rvm use [email protected]_gemset 

您還可以設置一個默認的紅寶石和寶石,當你打開一個新的終端窗口將被選中:

$ rvm use [email protected]_gemset --default 

或者,你可以設置你的Gemfile在你的應用程序,以便RVM切換到指定的紅寶石版和寶石,當你將目錄切換到應用程序的目錄:

的Gemfile:

ruby '1.9.3' #(no patch number allowed here) 
#ruby-gemset=myapp_gemset 

RVM將讀取你的Gemfile這一評論,然後切換到上一行的紅寶石版本,並在註釋中指定的寶石。

。 。

https://rvm.io/gemsets/deleting

刪除Gemsets

當你刪除一個寶石,RVM將提示您確認刪除。

$ rvm gemset use albinochipmunk 
$ rvm gemset delete albinochipmunk 

要跳過確認,傳遞--force標誌:

$ rvm gemset use albinochipmunk 
$ rvm --force gemset delete albinochipmunk 

默認情況下,RVM從當前選定Ruby解釋器 刪除gemsets。若要從不同的解釋器寶石,說 1.9.2,運行命令是這樣的:

$ rvm 1.9.2 do gemset delete albinochipmunk 

如果不使用寶石可言,你在「默認」的寶石的

https://rvm.io/gemsets/emptying

清空Gemsets

如果您清空一個寶石,RVM會提示您 確認。此操作將刪除安裝在gemset中的所有gem。

$ rvm gemset use albinochipmunk 
$ rvm gemset empty albinochipmunk 

要跳過確認,傳遞--force標誌:

$ rvm gemset use albinochipmunk 
$ rvm --force gemset empty albinochipmunk 
+0

我沒有使用寶石! ,我所做的只是安裝一個紅寶石版本1.8.7然後gem install rails -v 2.3.5 –

+0

請參閱我的文章的補充 - 您應該清空默認的gemset。 – 7stud

+0

如果您切換到ruby的版本'$ rvm use 1.8.7-p302',那麼執行'$ rvm gemset list',您會看到該版本的所有gemset。默認和全局gemsets會自動爲您創建。你可能不應該刪除它們。如果您切換到gemset'$ rvm gemset use mygemsA',您可以通過執行'$ gem list'來查看gemset中的所有寶石。這將允許您確認您的所有寶石是否進入了默認的寶石鑲嵌。 – 7stud

0

RVM安裝在global一些寶石寶石可以卸載這些寶石:

rvm @global do gem uninstall gem_name 

如果您不想使用任何寶石套裝(除單枚寶石級寶石套裝外)使用:此:

echo rvm_ignore_gemsets_flag=1 >> ~/.rvmrc 

,從現在起RVM將只使用單一的寶石 - 沒有global