Tuesday, December 4, 2012

Can't activate rack-, already activated rack- (Gem:::LoadError)

Encountered this one when I was trying to run my sinatra app on my work machine. Worked just fine at home, but when I ran

rackup config.ru -E development here I got:

/usr/lib/ruby/1.9.1/rubygems/specification.rb:1603:in `raise_if_conflicts': can't activate rack-1.2.5, already activated rack-1.4.1 (Gem::LoadError)
    from /usr/lib/ruby/1.9.1/rubygems/specification.rb:738:in `activate'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:51:in `block in require'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:50:in `each'
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:50:in `require'
    from /var/lib/gems/1.9.1/gems/backports-2.6.5/lib/backports/tools.rb:314:in `require_with_

Crap.

So then I did

 gem list | grep rack
crack (0.3.1)
rack (1.4.1, 1.4.0, 1.3.2, 1.2.5)
rack-cache (1.2, 1.0.3)
rack-mount (0.8.3, 0.6.14)
rack-oauth2 (1.0.0)
rack-pjax (0.6.0, 0.5.9)
rack-protection (1.2.0)
rack-proxy (0.3.7)
rack-ssl (1.3.2)
rack-test (0.6.2, 0.6.1, 0.5.7)

Look at all those rack versions. I read somewhere that bundle may be getting confused. So I did

sudo gem uninstall rack

And killed them all off.

Then I did sudo gem install rack, it installed 1.4.1, and magically, the command worked again.