"gem install" and "bundle install" do not install gem dependencies after manual gem deletion. How to inform Rubygems that gems were deleted manually?
Asked Answered
D

4

15

I was trying to build capybara-webkit on XP. I followed this instruction. It says to do bundle install:

 $ cd ruby193\capybara-webkit
 $ bundle install

This command installed many gems. Unfortunately I couldn't build capybara-webkit so I manually deleted all the gems it installed. After it I have problems with gem install and bundle install - these commands consider deleted gems as installed on my computer and do not install them if they are dependencies of some other gems I want to install now.

Please see an example. I do bundle install for capybara-webkit and it says that all the gems are present:

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.

But now I check these gems with bundle show and it says they all have been deleted:

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

It looks like Rubygems somehow somewhere remembers that gems were installed and considers that they are still present. It seems that gems should be deleted only by gem uninstall command and not manually.

Is there a way to clear Rubygems cache? How to inform Rubygems that some gems were deleted manually and so that it should consider them as uninstalled now?

Davide answered 4/7, 2013 at 16:15 Comment(0)
C
26

After deleting the gem manually, Delete the gemspec file for that gem present at "C:\Ruby187\lib\ruby\gems\1.8\specifications". Then try bundle install.

Chemiluminescence answered 5/7, 2013 at 6:25 Comment(1)
...or, if using RVM, delete the gemspec for that file at $HOME/.rvm/gems/ruby-X/specifications/Tearjerker
M
4

I know this answer comes very late but, having had the same problem myself, here is what worked for me; for anyone who may need it.

If you want to reinstall any gem you had manually removed, you will have to remove any reference to it in the directories in $HOME/.rvm/gems/ruby-X/ and then run bundle install. If you had manually deleted all of your gems, deleting everything in the $HOME/.rvm/gems/ruby-X/ directory and running bundle would reinstall them all.

Mcmullin answered 4/2, 2014 at 12:25 Comment(2)
the reference that had me stuck was in /specifications/ for what it's worthNerin
this worked for me. bundle show your_gem_name, go that directory and check the specifications folder, remove the gemspec and bundle update works fineFarmelo
N
4

In my case I had made a Gemfile in a directory and was doing a bundle install and I happened to deleted gem manually on os x due to which I was not able to install the gem again.

 1. gem list | grep your_gem_name
 2. uninstall your_gem_name
 3. removed Gemfile.lock
 4. bundle install from my Gemfile location 
Notum answered 11/7, 2014 at 18:46 Comment(0)
P
1

For bundler v2.0 and before run:

bundle install --force

For v2.1 and after run:

bundle install --redownload

This will reinstall all gems, but keep versions.

Paramedical answered 14/1, 2018 at 19:4 Comment(1)
I'm surprised this isn't higher, it worked like a charm.Pyrosis

© 2022 - 2024 — McMap. All rights reserved.