2017-03-03 283 views
2
[email protected]:~$ gem list 

*** LOCAL GEMS *** 

bigdecimal (1.2.8) 
did_you_mean (1.0.0) 
io-console (0.4.5) 
json (1.8.3) 
minitest (5.8.4) 
net-telnet (0.1.1) 
power_assert (0.2.7) 
psych (2.0.17) 
rake (10.5.0) 
rdoc (4.2.1) 
sass (3.4.23) 
test-unit (3.1.7) 
[email protected]:~$ sudo gem uninstall rake 
ERROR: While executing gem ... (Gem::InstallError) 
    rake is not installed in GEM_HOME, try: 
    gem uninstall -i /usr/share/rubygems-integration/all rake 
[email protected]:~$ sudo gem uninstall -i /usr/share/rubygems-integration/all rake 
Remove executables: 
    rake 

in addition to the gem? [Yn] Y 
ERROR: While executing gem ... (Gem::FilePermissionError) 
    You don't have write permissions for the /usr/share/rubygems-integration/all/bin directory. 
[email protected]:~$ ls /usr/share/rubygems-integration/all/ 
specifications 
[email protected]:~$ 

我不能特別卸載此寶石,既不如果好像它不存在使用它:( 。卸載紅寶石寶石

我的紅寶石verison是2.3.1.p112

回答

3

理想情況下,您可以使用RVM或rbenv來創建本地沙箱,並處理您的Ruby安裝和gems,而不是系統默認的。然後您不必使用sudo,您可以使用gem uninstall <gem>。它不允許您訪問原因,所以很難不小心搞亂Ruby系統。

如果您只需閱讀這些install directions即可使用RVM進行設置,然後將以前使用的寶石安裝到新環境中。它將爲您在管理Ruby和寶石的將來節省很多麻煩。

-

如果你不想這樣做,你可以試試這個答案

嘗試從這個related question這個答案。

gem list -d 'name of gem'並注意 「安裝在」 位置

sudo gem uninstall 'name of gem' -i 'the path noted above'

如果仍然返回權限錯誤。在上面的路徑中創建一個文件夾/ bin。繼續卸載,如第2步所述,仍然使用原始路徑(/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8)。

0

sudo不是一個魔術棒,施魔法「也無妨。」

當你列出你的寶石,你從用戶執行平原gem list。它列出了爲用戶安裝的寶石。之後,您嘗試sudo gem uninstall rake。爲什麼你期望超級用戶的寶石列表與用戶的列表相同?

要移除用gem list列出的用戶寶石,請使用gem uninstall rake。沒有sudo

要列出超級用戶的寶石,您嘗試使用sudo gem uninstall rake刪除,請使用sudo gem list。用sudo。在sudo

更多信息:http://aplawrence.com/Basics/sudo.html

+0

我卸載,但由於某種原因,有剩餘的一些文件。我手動刪除,現在一切正常。我試圖安裝耙並卸載它,現在工作正常。 –