For some gems on my machine, there are multiple versions:
$gem list bigdecimal
bigdecimal (1.2.6, 1.2.5)
$gem list io-console
io-console (0.4.3, 0.4.2)
$gem list json
json (1.8.2, 1.8.1)
...
I want to remove the old versions. I tried several commands:
$gem cleanup
Cleaning up installed gems...
Clean Up Complete
$sudo gem cleanup
Cleaning up installed gems...
Clean Up Complete
$gem cleanup json
Cleaning up installed gems...
Clean Up Complete
$sudo gem cleanup json
Cleaning up installed gems...
Clean Up Complete
but the old versions are not removed. Why are the old versions not detected by cleanup? How can I remove them?
Update Strange thing is that, I can manually uninstall the newer versions but not the old ones. For example,
$ sudo gem uninstall json --version 1.8.1
ERROR: While executing gem ... (Gem::InstallError)
gem "json" cannot be uninstalled because it is a default gem
$ sudo gem uninstall json --version 1.8.2
Successfully uninstalled json-1.8.2
Update What is a default gem? Why can't it be deleted?
Update If I have a default old version, does it mean that a newer version is not in use and the default one is called by the command require?
It's likely that gem cleanup isn't working because you have something installed with dependencies on these old versions. You can check what has dependencies on your old gems by running gem dependency your-gem-name --reverse-dependencies.
If that command doesn't show you any dependencies you can manually remove the old versions with gem uninstall:
# remove specific version
gem uninstall your-gem-name --version 2.1.0
# remove all versions less than a certain version
gem uninstall your-gem-name --version '<2.1.0'
Related
I have installed installed RVM and tried to setup compass - had some errors, so I tried to do it by installing Ruby and then doing everything step by step. THe thing is RVM gems conflict with the ruby gems and whatever I do, even though I Removed .rvm and ran rvm implode and searched for the sas 3.3.0 folder and deleted it manually it still says that ..., because sass-3.2.19 conflicts with sass (~> 3.3.0) . WHen I do gem list it does not show 3.3.0 , when I try to run compass it's always the same, i'm tired of searching for solutions, but I don't want to reinstall my ubuntu and set everything all up again.
What else could I try to remove that hidden gem from the system? I tried everything I could find - no use at all! There has to be a way to exclude taht dependency to not include 3.3.0 at all!
Maybe installing rvm and creating new gemset would help?
These commands might help you out:
# remove all old versions of the gem
gem cleanup rjb
# choose which ones you want to remove
gem uninstall rjb
# remove version 1.1.9 only
gem uninstall rjb --version 1.1.9
# remove all versions less than 1.3.4
gem uninstall rjb --version '<1.3.4'
I have selected a gemset with
rvm use ruby-2.1.2#deploy
in my gemfile I have:
gem 'transip', :git => 'git://github.com/rempargo/transip.git'
then I run bundle install and get the following output:
....
....
Installing wasabi 3.3.0
Installing savon 2.5.1
Using transip 0.4.2 from git://github.com/rempargo/transip.git (at master)
Using bundler 1.6.2
Your bundle is updated!
But when I do gem list all gems except the transip one are listed.
The other gems are not installed in gemset 'ruby-2.1.2' or 'ruby-2.1.2#global', but are really installed in the gemset ruby-2.1.2#deploy
I tried also to use bundle exec install although I never used the 'exec' before, but it does not work.
Is there a problem using bundler and rvm when using gems that uses a link to a repository?
I'm using:
Mac OS X 10.9.3 (With command-line tools installed)
rvm 1.25.26
bundler 1,6,2
P.S. This all happened after upgrading to Maverick, when some libraries where not working anymore, and I had to install ruby again with rvm.
gem list will show all the gems installed on your system
bundle show gem_namewill give you whether that gem is installed in your current application bundled gemset
I had tons of gems on my local machine which I were installed before and after RVM, so I decided to wipe them all and reinstall. Everything seemed to go ok, except bundler:
gem list
.....
bundler (1.1.3, 1.0.22)
I don't know why 1.0.22 is still there, and I can't figure out how to get rid of it!
$ gem cleanup
Cleaning up installed gems...
Attempting to uninstall bundler-1.0.22
Unable to uninstall bundler-1.0.22:
Gem::InstallError: gem "bundler" is not installed
Clean Up Complete
$ gem uninstall bundler-1.0.22
INFO: gem "bundler-1.0.22" is not installed
UPDATE 1
Path info as requested by Andrew
/Users/brandon/.rvm/gems/ruby-1.9.3-p125-perf#global/gems/bundler-1.0.22/
What's most likely happening is that the two versions of Bundler are installed in two different gemsets, one of which is inheriting from the other. 1.0.22 is probably installed in the global gemset (rvm use #global), or "root" gemset (rvm use <ruby_version>). Once you're in the gemset that has 1.0.22 installed, you should be able to remove it with gem uninstall bundler.
I have several versions of a Ruby gem:
$ gem list
rjb (1.3.4, 1.3.3, 1.1.9)
How can I remove old versions but keep the most recent?
# remove all old versions of the gem
gem cleanup rjb
# choose which ones you want to remove
gem uninstall rjb
# remove version 1.1.9 only
gem uninstall rjb --version 1.1.9
# remove all versions less than 1.3.4
gem uninstall rjb --version '<1.3.4'
For removing older versions of all installed gems, following 2 commands are useful:
gem cleanup --dryrun
Above command will preview what gems are going to be removed.
gem cleanup
Above command will actually remove them.
Way to clean out any old versions of gems.
sudo gem cleanup
If you just want to see a list of what would be removed you can use:
sudo gem cleanup -d
You can also cleanup just a specific gem by specifying its name:
sudo gem cleanup gemname
for remove specific version like 1.1.9 only
gem uninstall gemname --version 1.1.9
If you still facing some exception to install gem, like:
invalid gem: package is corrupt, exception while verifying: undefined method `size' for nil:NilClass (NoMethodError) in /home/rails/.rvm/gems/ruby-2.1.1#project/cache/nokogiri-1.6.6.2.gem
the, you can remove it from cache:
rm /home/rails/.rvm/gems/ruby-2.1.1#project/cache/nokogiri-1.6.6.2.gem
For more detail:
http://blog.grepruby.com/2015/04/way-to-clean-up-gem-or-remove-old.html
Try something like gem uninstall rjb --version 1.3.4.
gem cleanup uses system commands. Installed gems are just directories in the filesystem. If you want to batch delete, use rm -R.
gem environment and note the value of GEM PATHS
cd <your-gem-paths>/gems
ls -1 |grep rjb- |xargs rm -R
You might need to set GEM_HOME for the cleanup to work. You can check what paths exist for gemfiles by running:
gem env
Take note of the GEM PATHS section.
In my case, for example, with gems installed in my user home:
export GEM_HOME="~/.gem/ruby/2.4.0"
gem cleanup
bundler clean
Stopped the message showing for me, as a last step after I tried all of the above.
I'm trying to install the thinking sphinx gem, which is on gemcutter.org
When I run the command
gem sources -a http://gemcutter.org
I get the error:
Error fetching http://gemcutter.org:
bad response Not Found 404 (http://gemcutter.org/specs.4.8)
If I change the above URL to http://gemcutter.org.specs.4.8.gz it finds a file. How do I tell rubygems to download with the .gz extension?
It looks like a temporary Gemcutter failure. It works fine to me.
Make sure you are running the latest RubyGems version and install the latest gemcutter gem.
$ gem install gemcutter --source http://gemcutter.org
With the gemcutter GEM you type gem tumble to add Gemcutter as source.
$ gem tumble
EDIT. I just noticed you are using a really outdated RubyGems version.
Update RubyGems first.
$ gem update --system
If it tells you there's nothing to update, you have a buggy version (RubyGems 1.2 selfupdate was buggy). Upgrade with the following command.
$ gem install rubygems-update
$ update_rubygems
Then add the source.
What version of Rubygems are you running (gem --version)? If less than 1.3.5, you may want to update Rubygems and try again. (gem update --system)
This is working for me with the following sources defined:
http://gems.rubyforge.org/
http://gems.github.com
as I said this is working for me:
gem install thinking-sphinx \
> --source http://gemcutter.org
If you're upgrading, you should read this:
http://freelancing-god.github.com/ts/en/upgrading.html
Successfully installed thinking-sphinx-1.3.2
Successfully installed activesupport-2.3.4
2 gems installed
Installing ri documentation for thinking-sphinx-1.3.2...
Installing ri documentation for activesupport-2.3.4...