Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

rubygems

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?

like image 454
Green Avatar asked Jul 04 '13 16:07

Green


4 Answers

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.

like image 180
user3791 Avatar answered Oct 26 '22 12:10

user3791


Run:

bundle install --force

This will reinstall all gems, but keep versions.

like image 33
Artem P Avatar answered Oct 26 '22 11:10

Artem P


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.

like image 45
Muaad Avatar answered Oct 26 '22 11:10

Muaad


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 
like image 44
AkD Avatar answered Oct 26 '22 12:10

AkD