当我尝试使用sudo gem cleanup rails
我收到以下错误:
Cleaning up installed gems...
Attempting to uninstall rails-2.3.5
Unable to uninstall rails-2.3.5:
Gem::InstallError: cannot uninstall, check `gem list -d rails`
Attempting to uninstall rails-1.2.6
Unable to uninstall rails-1.2.6:
Gem::InstallError: cannot uninstall, check `gem list -d rails`
gem list -d rails
导致:
rails (2.3.8, 2.3.5, 1.2.6)
Author: David Heinemeier Hansson
Rubyforge: http://rubyforge.org/projects/rails
Homepage: http://www.rubyonrails.org
Installed at (2.3.8): /Library/Ruby/Gems/1.8
(2.3.5): /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
(1.2.6): /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
Web-application framework with template engine, control-flow layer,
and ORM.
任何人都知道什么是错的?
答案 0 :(得分:13)
经过一些长时间的搜索后发现原因是由于路径不存在。无法卸载因为系统没有搜索/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
在粒度级别,而不是gem cleanup rails
,您只需使用uninstall命令并键入:
gem uninstall rails -i /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
然后您可能遇到与不存在的路径相关的另一个问题,此时,您应该使用以下命令创建目录:
mkdir /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/bin
现在所有卸载都应该可以正常运行。我建议通过执行以下功能来重新安装干净的宝石:
gem list --no-versions | sed -e '/^(*|$)/d' > installed_gems
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
cat installed_gems | xargs sudo gem install
答案 1 :(得分:1)
结帐http://gabrito.com/post/mac-os-x-gem-cleanup-failing,建议:
sudo sh -c 'GEM_HOME=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 gem cleanup'