I did a bundle show
and get the complete path to a gem directory.
Unfortunately, I removed the directory using rm -r gem_path
. Then my rails ap
You can always use:
gem pristine acts-as-taggable-on
pristine - Restores installed gems to pristine condition from files located in the gem cache
If you just want to restore the gem for the current project you should run:
bundle exec gem pristine acts-as-taggable-on
If using RVM with gems in ~/.rvm/
, this works if bundle
is not re-installing a gem.
First, delete the gem source:
bundle show $GEM
rm -rf $PATH_TO_GEM
Clear out the compiled gem cache:
rm -rf ~/.rvm/gems/ruby-$RUBYVERSION[@$GEMSET]/cache/$GEM.gem
Also clear out bundler's spec cache:
rm -rf ~/.rvm/gems/ruby-$RUBYVERSION[@$GEMSET]/specifications/$GEM*gemspec
Then you can re-install:
bundle install
If you've installed into ./bundle/vendor
or similar, you need to remove the gem first but explicitly specify the GEM_HOME, e.g.
GEM_HOME=./vendor/bundle/ruby/2.3.0/ gem uninstall rmagick
This is by far the simplest way to uninstall gems installed using bundler into a vendor directory. Ideally, there would be a command bundle uninstall
or bundle reinstall
, etc.
If your goal is to simply reinstall, the following command will help:
GEM_HOME=./vendor/bundle/ruby/2.3.0/ gem uninstall rmagick && sudo -u http bundle install
If you're like me and have several web-applications under a directory (e.g. /srv/http
), the following does it in all directories:
cd /srv/http
for d in ./*/ ; do (cd "$d" && sudo -u http GEM_HOME=./vendor/bundle/ruby/2.4.0/ gem uninstall --force rmagick && sudo -u http bundle install); done
bundle exec gem uninstall <gem_name>
- uninstalls gem from the bundle (the <app_root>/vendor/bundle/ruby/2.3.0/gems/
path). This is equivalent to the answer @ioquatix gave, but is the slightly more convenient solution that he was looking for.
gem uninstall <gem_name>
- uninstalls gem only from the global gemset in the system
If you're trying to reinstall rake, gem pristine rake
will fail with Skipped rake-10.X.X, it is a default gem
and bundle won't install it either, because it can't uninstall it.
If you're using rvm, it seems the easiest was is simply to do a rvm reinstall 2.x.x
. At least for me, rvm repair all
also didn't help.
The same probably goes for all other default gems. I'll just list them here so that the desperate googlers find some help:
First I did a gem q --L
, the shortcut for gem query --local
. It outputs me the all the local gems installed.
actionmailer (3.2.8, 3.2.6, 3.2.1, 3.1.0)
actionpack (3.2.8, 3.2.6, 3.2.1, 3.1.0)
activemodel (3.2.8, 3.2.6, 3.2.1, 3.1.0)
activerecord (3.2.8, 3.2.6, 3.2.1, 3.1.0)
activeresource (3.2.8, 3.2.6, 3.2.1, 3.1.0)
activesupport (3.2.8, 3.2.6, 3.2.1, 3.1.0)
acts-as-taggable-on (2.3.3)
...
And then, following DVG advice, I uninstalled the gem using its correct name gem uninstall acts-as-taggable-on
and ran bundle install
. After that I was able to rails c
or rails s
again without any problem.