# Rubygems out of sync?

**URL:** <https://www.ruby-forum.com/t/rubygems-out-of-sync/157832>\
**Category:** Ruby\
**Created:** [January 15, 2009, 7:22pm UTC](https://www.ruby-forum.com/t/rubygems-out-of-sync/157832 "2009-01-15T19:22:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [January 15, 2009, 7:22pm UTC](https://www.ruby-forum.com/t/rubygems-out-of-sync/157832/1 "2009-01-15T19:22:06Z")

</div>

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.

Thanks!

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [February 20, 2009, 8:05pm UTC](https://www.ruby-forum.com/t/rubygems-out-of-sync/157832/2 "2009-02-20T20:05:07Z")

</div>

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  
case.

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

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

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  
former)  
Now it worked.  
So it seems that the specifications dir is where “gem list” gets its  
list.  
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:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/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  
“gem”

hope this helps  
winawards  
rhubarb

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [February 20, 2009, 8:20pm UTC](https://www.ruby-forum.com/t/rubygems-out-of-sync/157832/3 "2009-02-20T20:20:54Z")

</div>

Thanks a lot for posting this. That fixed everything.
