Forum: Ruby rubygems out of sync?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
328f0bb678423fcea01ebe3b0edc74e6?d=identicon&s=25 Ben Johnson (benjohnson)
on 2009-01-15 19:22
rubygems is giving me some problems, and I was hoping someone here might
have an idea what is going on. When I type:

sudo gem list

I get a bunch of gems that I have uninstalled. For example:

$ sudo gem uninstall merb-slices
ERROR:  While executing gem ... (Gem::InstallError)
    Unknown gem merb-slices >= 0

But is show up in my gem list. How do I fix this? Is there anyway to
rebuild that list? I looked through the docs and couldn't find anything.

61396c69040bbc56dbad1c5c71ac27d2?d=identicon&s=25 Rover Rhubarb (rhubarb)
on 2009-02-20 20:05
I came across this question several times (and no answers!) while trying
to solve almost exactly the same problem only with the rake gem in my

In the end I explored through the gem code itself and resolve the
problem of my gem list being out of synch with my actual gems in a
couple of ways:

gem cleanup

this is the built in command that's supposed to do it for you - I got
some errors from it, but it fixed some inconsistencies

if you look in your gems directory you see a structure like this:
[~/.gem/ruby/1.8] ls
bin/            cache/          doc/            gems/

Now I had foolishly deleted some gems out of the gems directory, which
is how the list got out of synch. So I went into the cache directory and
deleted the matching .gem files. "gem list" was still wrong. Next, I
went into "specifications" and deleted the .gemspec files that matched
my deleted gems. (basically I compared the contents of gems/ and
specifications/ and deleted from the latter anything not listed in the
Now it worked.
So it seems that the specifications dir is where "gem list" gets its
This also seemed to solve my problem of the rake command not finding the
rake library.

Some other things to note:
- The gem FAQ suggests you delete source_cache file - which I did and it
didnt hurt (in fact it may have been this that fixed my rake problem -
though it definitely didnt fix my gem list problem)

- On Mac OS X I have no fewer than 3 different gem locations:
     - /Library/Ruby/Gems/1.8
     - /Users/chris/.gem/ruby/1.8

the easiest way to see this list - along with a lot of other useful info
is to use "gem env"

- Also note that some people have report weird synch problems caused by
different installations of the gem command in different parts of their
PATH for the super user and their regular user. Which is to say, "gem"
and "sudo gem" were running different executables for "gem" and were
storing gems in different places and had different environments. This
was not the problem I had, but to find out if its your problem run
"which gem" and "sudo which gem" and see that they point to the same

hope this helps
328f0bb678423fcea01ebe3b0edc74e6?d=identicon&s=25 Ben Johnson (benjohnson)
on 2009-02-20 20:20
Thanks a lot for posting this. That fixed everything.
This topic is locked and can not be replied to.