" gem install"和"捆绑安装"手动删除gem后不要安装gem依赖项。如何通知Rubygems手动删除宝石?

时间:2013-07-04 16:15:50

标签: rubygems

我试图在XP上构建capybara-webkit。我遵循this指令。它说要做bundle install

 $ cd ruby193\capybara-webkit
 $ bundle install

此命令安装了许多宝石。不幸的是,我无法构建capybara-webkit,因此我手动删除了它安装的所有gem。之后我遇到了gem installbundle install的问题 - 这些命令会考虑我计算机上安装的已删除的gem,如果它们是我想要安装的其他一些宝石的依赖项,则不要安装它们。

请看一个例​​子。我为bundle install做了capybara-webkit,它说所有的宝石都存在:

C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\capybara-webkit>bundle install
Resolving dependencies...
Using rake (0.9.2)
Using addressable (2.3.2)
Using bundler (1.3.5)
Using appraisal (0.4.0)
Using mime-types (1.22)
Using nokogiri (1.5.9)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using xpath (2.0.0)
Using capybara (2.1.0)
Using json (1.8.0)
Using capybara-webkit (1.0.0) from source at .
Using ffi (1.2.0)
Using childprocess (0.3.6)
Using diff-lcs (1.1.2)
Using websocket (1.0.6)
Using libwebsocket (0.1.7.1)
Using subexec (0.0.4)
Using mini_magick (3.2.1)
Using multi_json (1.5.0)
Using rack-protection (1.3.2)
Using rspec-core (2.6.4)
Using rspec-expectations (2.6.0)
Using rspec-mocks (2.6.0)
Using rspec (2.6.0)
Using rubyzip (0.9.9)
Using selenium-webdriver (2.27.2)
Using tilt (1.3.3)
Using sinatra (1.3.5)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

但现在我用bundle show检查这些宝石,并说它们都被删除了:

C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\capybara-webkit>bundle show sinatra
The gem sinatra has been deleted. It was installed at:
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/sinatra-1.3.5

C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\capybara-webkit>bundle show selenium-webdriver
The gem selenium-webdriver has been deleted. It was installed at:
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.27.2

C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\capybara-webkit>bundle show mini_magick
The gem mini_magick has been deleted. It was installed at:
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mini_magick-3.2.1

看起来Rubygems不知何故在某处记得安装了宝石并认为它们仍然存在。似乎只应通过gem uninstall命令删除gem,而不是手动删除。

有没有办法清除Rubygems缓存?如何通知Rubygems手动删除了一些宝石,以便它现在应该将它们视为已卸载?

4 个答案:

答案 0 :(得分:23)

手动删除gem后,删除“C:\ Ruby187 \ lib \ ruby​​ \ gems \ 1.8 \ specifications”中存在的gem的gemspec文件。然后尝试捆绑安装。

答案 1 :(得分:4)

我知道这个答案来得很晚但是,我自己遇到了同样的问题,这对我有用;对于任何可能需要它的人。

如果要重新安装手动删除的任何gem,则必须在$HOME/.rvm/gems/ruby-X/的目录中删除对它的任何引用,然后运行bundle install。如果您手动删除了所有宝石,删除$HOME/.rvm/gems/ruby-X/目录中的所有内容并运行bundle将重新安装所有宝石。

答案 2 :(得分:4)

在我的情况下,我在一个目录中创建了一个Gemfile,并且正在进行捆绑安装,我碰巧在os x上手动删除了gem,因为我无法再次安装gem。

 1. gem list | grep your_gem_name
 2. uninstall your_gem_name
 3. removed Gemfile.lock
 4. bundle install from my Gemfile location 

答案 3 :(得分:0)

执行命令

bundle install --force

这将重新安装所有宝石,但保留版本。