Stuck with a gem that just wont uninstall

Yesterday i was updating all my ruby gems. During the update a got disturbed by something so i did not pay attention what gems got updated.

This morning i found my current app not starting up.

This is how i solved it

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#script/server
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
Exiting
/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1-java/lib/mongrel/init.rb (MissingSourceFile)
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:495:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:342:in `new_constants_in'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:495:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/gem_plugin-0.2.3/lib/gem_plugin.rb:134:in `load'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:184:in `each'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:184:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/gem_plugin-0.2.3/lib/gem_plugin.rb:112:in `load'
... 21 levels...
from /opt/local/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/commands/server.rb:39
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from script/server:3`

Ok, so now what? I know i do not run java. Not just yet.

My update last night must have installed a mongrel-1.1-java, no biggy i just uninstall.

1
2
3
4
5
6
7
8
9
10
11
12
13
gem uninstall mongrel

Select gem to uninstall:
1. mongrel-1.0.1
2. mongrel-1.0.2
3. mongrel-1.1
4. mongrel-1.1-java
5. mongrel-1.1.1
6. mongrel-1.1.4
7. All versions
> 4
INFO:  In order to remove mongrel, please execute:
gem uninstall mongrel --install-dir=/opt/local/lib/ruby/gems/1.8

If i add the install dir i get the same result. Just for fun i try to delete the ruby-java-gem folder -> /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1-jruby/

But still the same error and gem still think the gem is installed.

This became my solution

For each installed gem there is a gemspec file that holds information about the gem. After deleting the gemspec for ruby-1.1-java everything went back to normal.

1
sudo rm /opt/local/lib/ruby/gems/1.8/specifications/mongrel-1.1.1.gemspec

Hope this can help someone ūüėČ

Posted in Ruby at May 13th, 2008. Trackback URI: trackback Tags: , Written by: 
  • teemoo

    Great, thanks! I had the same bug since a few days. Your solution is not very elegant but it worked out much better than everything I tried before…

  • Mathias Stjernstr√∂m

    I know. It’s dirty but i couldn’t find a better solution at the moment.

    I’m glad it helped!

    Cheers!

  • http://www.ultrasaurus.com Sarah

    I had the same problem, but my gem specs weren’t in the same place. To find out where they were installed:

    gem list -d mongrel

    Thanks!
    Sarah

  • Mathias Stjernstr√∂m

    Thanks for sharing Sarah!

It's past my bedtime is using WP-Gravatar