# Gem cleanup problem

**URL:** <https://www.ruby-forum.com/t/gem-cleanup-problem/161986>\
**Category:** Ruby\
**Created:** [March 4, 2009, 3:30pm UTC](https://www.ruby-forum.com/t/gem-cleanup-problem/161986 "2009-03-04T15:30:23Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [March 4, 2009, 3:30pm UTC](https://www.ruby-forum.com/t/gem-cleanup-problem/161986/1 "2009-03-04T15:30:23Z")

</div>

I’m running Kubuntu Linux 8.10, and Rubygems 1.3.1.

I’m trying to remove a sizable number of outdated gem versions, using  
the ‘gem update’ command. Initially, it appeared to be choking on  
RedCloth. I kept getting:

~$ sudo gem cleanup  
Cleaning up installed gems…  
Attempting to uninstall RedCloth-4.1.1  
ERROR: While executing gem … (Gem::InstallError)  
Unknown gem RedCloth = 4.1.1

My immediately previous ‘gem list’ had shown (among other things) -

RedCloth (4.1.9, 4.1.1)

So I tried to uninstall RedCloth completely, thinking there must be  
something wrong with it (although I’d seen no indication of this  
elsewhere). Rubygems reported successfully uninstalling v. 4.1.9. No  
mention of 4.1.1. It still appeared in the ‘gem list’.

Reissuing the command, I get this:

$ sudo gem uninstall RedCloth  
ERROR: While executing gem … (Gem::InstallError)  
Unknown gem RedCloth \>= 0

So I went after it manually, and just deleted the gem and associated  
docs.

But the problem just reappeared, with a different gem. Not a RedCloth  
problem after all.

$ sudo gem cleanup  
Cleaning up installed gems…  
Attempting to uninstall bones-2.3.1  
ERROR: While executing gem … (Gem::InstallError)  
Unknown gem bones = 2.3.1  
tomc@tomc-desktop:~$

I don’t understand the problem here. Can anyone offer me a clue?

Thanks!

Tom

–

```auto
Tom C., MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< removed_email_address@domain.invalid >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)

```

---

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [March 4, 2009, 7:06pm UTC](https://www.ruby-forum.com/t/gem-cleanup-problem/161986/2 "2009-03-04T19:06:35Z")

</div>

lasitha wrote:

> Which seems to have a workaround detailed at the bottom of:  
> [Problem with "gem cleanup" on OS X 10.5 - Ruby - Ruby-Forum](http://www.ruby-forum.com/topic/170342)
> 
> HTH,  
> lasitha

Thanks very much for the assist. I have no knowledge of this problem, so  
your help is a potential lifesaver - will go check this info. out  
immediately!

t.

–

```auto
Tom C., MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< removed_email_address@domain.invalid >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)

```

---

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [March 4, 2009, 6:27pm UTC](https://www.ruby-forum.com/t/gem-cleanup-problem/161986/3 "2009-03-04T18:27:41Z")

</div>

On Wed, Mar 4, 2009 at 7:57 PM, Tom C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ~$ sudo gem cleanup  
> Cleaning up installed gems… Attempting to uninstall RedCloth-4.1.1  
> ERROR: While executing gem … (Gem::InstallError)  
> Unknown gem RedCloth = 4.1.1

Tom, sounds a lot like #22770:  
[http://rubyforge.org/tracker/index.php?func=detail&aid=22770&group\_id=126&atid=575](http://rubyforge.org/tracker/index.php?func=detail&aid=22770&group_id=126&atid=575)

Which seems to have a workaround detailed at the bottom of:  
[http://www.ruby-forum.com/topic/170342](http://www.ruby-forum.com/topic/170342)

HTH,  
lasitha

---

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [March 4, 2009, 7:30pm UTC](https://www.ruby-forum.com/t/gem-cleanup-problem/161986/4 "2009-03-04T19:30:03Z")

</div>

On Mar 4, 2009, at 06:27, Tom C. wrote:

> Unknown gem RedCloth = 4.1.1
> 
> Cleaning up installed gems…  
> Attempting to uninstall bones-2.3.1  
> ERROR: While executing gem … (Gem::InstallError)  
> Unknown gem bones = 2.3.1  
> tomc@tomc-desktop:~$
> 
> I don’t understand the problem here. Can anyone offer me a clue?

gem cleanup doesn’t handle multiple gem repos well yet, this may be  
your problem:

$ gem list -d rails

\*\*\* LOCAL GEMS \*\*\*

rails (2.2.2, 1.2.6)  
Author: David Heinemeier H.  
Rubyforge: [http://rubyforge.org/projects/rails](http://rubyforge.org/projects/rails)  
Homepage: [http://www.rubyonrails.org](http://www.rubyonrails.org)  
Installed at (2.2.2): /Library/Ruby/Gems/1.8  
(1.2.6): /System/Library/Frameworks/Ruby.framework/  
Versions/1.8/usr/lib/ruby/gems/1.8  
[…]  
$ sudo gem cleanup rails  
Password:  
Cleaning up installed gems…  
:0:Warning: Gem::SourceIndex#search support for Regexp patterns is  
deprecated  
Attempting to uninstall rails-1.2.6  
ERROR: While executing gem … (Gem::InstallError)  
Unknown gem rails = 1.2.6  
$

---

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [March 4, 2009, 7:31pm UTC](https://www.ruby-forum.com/t/gem-cleanup-problem/161986/5 "2009-03-04T19:31:14Z")

</div>

On Mar 4, 2009, at 10:25, Tom C. wrote:

> Uh…which brings up the subject of tests. I now understand enough  
> about test to suggest that perhaps the test suite for rubygems isn’t  
> doing its job. Just a thought.

Some areas are covered very well, others are not.

> Time for a little “heckle” session?

I am eagerly awaiting your patches. Dedicated patch providers get  
commit.

---

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [March 4, 2009, 7:27pm UTC](https://www.ruby-forum.com/t/gem-cleanup-problem/161986/6 "2009-03-04T19:27:42Z")

</div>

lasitha wrote:

> Which seems to have a workaround detailed at the bottom of:  
> [Problem with "gem cleanup" on OS X 10.5 - Ruby - Ruby-Forum](http://www.ruby-forum.com/topic/170342)
> 
> HTH,  
> lasitha

OK, after digesting the information you kindly directed me to, here’s  
what the consensus appears to be:

1. the “gem clean” command is broken, at least some of the time. For me,  
in my environment, all the time.
2. the “workaround” is to uninstall each gem and reinstall it. With  
about 25 gems installed, that definitely a delightful prospect. It’s  
even worse when one considers that, as I documented in my original  
email, the ‘gem uninstall’ command is also broken.

Uh…which brings up the subject of tests. I now understand enough about  
test to suggest that perhaps the test suite for rubygems isn’t doing its  
job. Just a thought. Time for a little “heckle” session?

Oh well. Having 60 gems installed when only 25 are needed is tolerable.  
Won’t need a bailout on this one…!

t.  
But what do I know?

–

```auto
Tom C., MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< removed_email_address@domain.invalid >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)

```

---

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [March 4, 2009, 8:02pm UTC](https://www.ruby-forum.com/t/gem-cleanup-problem/161986/7 "2009-03-04T20:02:25Z")

</div>

On Wed, Mar 4, 2009 at 11:55 PM, Tom C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> the consensus appears to be:
> 
> 1. the “gem clean” command is broken, at least some of the time. For me, in  
> my environment, all the time.
> 2. the “workaround” is to uninstall each gem and reinstall it. With about 25  
> gems installed, that definitely a delightful prospect. It’s even worse when  
> one considers that, as I documented in my original email, the ‘gem  
> uninstall’ command is also broken.

As Eric noted, the trouble comes about when you have multiple  
repositories. There may be good reason for such a setup, but if there  
isn’t _and_ most of your outdated gems are in one of them, you could  
just blow that one away (rm -rf).

In my case the only reason i’ve had multiple repos is when i forget to  
sudo and end up with gems in ~/.gem. I’ve blown that one away a  
couple times and that hasn’t bothered rubygems any, as far i can tell.

Cheers,  
lasitha.

---

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [March 4, 2009, 9:58pm UTC](https://www.ruby-forum.com/t/gem-cleanup-problem/161986/8 "2009-03-04T21:58:43Z")

</div>

Eric H. wrote:

> > RedCloth-4.1.1
> 
> your problem:  
> (1.2.6):  
> Unknown gem rails = 1.2.6  
> $

Bingo. That’s it. I have ruby 1.8.7 installed, and recently installed  
1.9 as well. It never occurred to me that Rubygems was catching both  
installs, and that is clearly the case. Hadn’t used the ‘gem list -d {}’  
command until I read your email. Problem explained, if not solved.  
Interesting…

A day full of bright spots of all sorts!

t.

–

```auto
Tom C., MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< removed_email_address@domain.invalid >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)

```

---

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [March 5, 2009, 1:43am UTC](https://www.ruby-forum.com/t/gem-cleanup-problem/161986/9 "2009-03-05T01:43:34Z")

</div>

On Mar 4, 2009, at 12:56, Tom C. wrote:

> > gem cleanup doesn’t handle multiple gem repos well yet, this may be  
> > Installed at (2.2.2): /Library/Ruby/Gems/1.8  
> > Unknown gem rails = 1.2.6  
> > $
> 
> Bingo. That’s it. I have ruby 1.8.7 installed, and recently  
> installed 1.9 as well. It never occurred to me that Rubygems was  
> catching both installs, and that is clearly the case. Hadn’t used  
> the ‘gem list -d {}’ command until I read your email. Problem  
> explained, if not solved. Interesting…

I forgot the workaround:

sudo sh -c ‘GEM\_PATH=`gem env home` gem cleanup’

---

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [March 4, 2009, 9:53pm UTC](https://www.ruby-forum.com/t/gem-cleanup-problem/161986/10 "2009-03-04T21:53:59Z")

</div>

Eric H. wrote:

> On Mar 4, 2009, at 10:25, Tom C. wrote:
> 
> > Uh…which brings up the subject of tests. I now understand enough  
> > about test to suggest that perhaps the test suite for rubygems isn’t  
> > doing its job. Just a thought.
> 
> Some areas are covered very well, others are not.  
> Ahem. Familiar with the problem am I.
> 
> > Time for a little “heckle” session?
> 
> I am eagerly awaiting your patches. Dedicated patch providers get  
> commit.

oh man. Your apparent (if not actual!) faith in my coding abilities is  
easily the highlight of my day. In only it were true…

t.

–

```auto
Tom C., MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< removed_email_address@domain.invalid >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)

```

---

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [March 5, 2009, 2:28am UTC](https://www.ruby-forum.com/t/gem-cleanup-problem/161986/11 "2009-03-05T02:28:38Z")

</div>

Eric H. wrote:

> > > Homepage: [http://www.rubyonrails.org](http://www.rubyonrails.org)  
> > > Attempting to uninstall rails-1.2.6
> 
> I forgot the workaround:
> 
> sudo sh -c ‘GEM\_PATH=`gem env home` gem cleanup’

Ah, lovely. Thanks a lot!

t.

–

```auto
Tom C., MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< removed_email_address@domain.invalid >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)

```

---

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [March 20, 2009, 1:11am UTC](https://www.ruby-forum.com/t/gem-cleanup-problem/161986/12 "2009-03-20T01:11:10Z")

</div>

> As Eric noted, the trouble comes about when you have multiple  
> repositories. There may be good reason for such a setup, but if there  
> isn’t _and_ most of your outdated gems are in one of them, you could  
> just blow that one away (rm -rf).
> 
> In my case the only reason i’ve had multiple repos is when i forget to  
> sudo and end up with gems in ~/.gem. I’ve blown that one away a  
> couple times and that hasn’t bothered rubygems any, as far i can tell.

Hi,

Thanks for the tip, I just run into this issue, and you saved my day. Is  
it safe to do ‘rm -rf’? I only want to keep 1 repo.
