Gem ::安装错误

时间:2010-06-15 21:33:56

标签: ruby-on-rails

当我尝试使用sudo gem cleanup rails

清理我的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.

任何人都知道什么是错的?

2 个答案:

答案 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'