Opinionated Programmer - Jo Liss's musings on enlightened software development.

Bundler problem: "You have already activated launchy 0.3.7"

I just wanted to post this in case anyone else is getting a weird error saying “You have already activated launchy 0.3.7. Consider using bundle exec.” – even though you are already using bundle exec. Here is the full error message:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/usr/bin/ruby1.9.1 -S bundle exec rspec ...
/var/lib/gems/1.9.1/gems/bundler-1.1.pre.1/lib/bundler/runtime.rb:31:in `block in
  setup': You have already activated launchy 0.3.7, but your Gemfile requires
  launchy 0.4.0. Consider using bundle exec. (Gem::LoadError)
        from /var/lib/gems/1.9.1/gems/bundler-1.1.pre.1/lib/bundler/spec_set.rb:12:in `block in each'
        from /var/lib/gems/1.9.1/gems/bundler-1.1.pre.1/lib/bundler/spec_set.rb:12:in `each'
        from /var/lib/gems/1.9.1/gems/bundler-1.1.pre.1/lib/bundler/spec_set.rb:12:in `each'
        from /var/lib/gems/1.9.1/gems/bundler-1.1.pre.1/lib/bundler/runtime.rb:17:in `setup'
        from /var/lib/gems/1.9.1/gems/bundler-1.1.pre.1/lib/bundler.rb:109:in `setup'
        from /var/lib/gems/1.9.1/gems/bundler-1.1.pre.1/lib/bundler/cli.rb:307:in `exec'
        from /var/lib/gems/1.9.1/gems/bundler-1.1.pre.1/lib/bundler/vendor/thor/task.rb:22:in `run'
        from /var/lib/gems/1.9.1/gems/bundler-1.1.pre.1/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
        from /var/lib/gems/1.9.1/gems/bundler-1.1.pre.1/lib/bundler/vendor/thor.rb:246:in `dispatch'
        from /var/lib/gems/1.9.1/gems/bundler-1.1.pre.1/lib/bundler/vendor/thor/base.rb:389:in `start'
        from /var/lib/gems/1.9.1/gems/bundler-1.1.pre.1/bin/bundle:13:in `<top (required)>'
        from /var/lib/gems/1.9.1/bin/bundle:19:in `load'
        from /var/lib/gems/1.9.1/bin/bundle:19:in `<main>'
rake aborted!
ruby -S bundle exec rspec ... failed

This can happen if your gem or app is requiring launchy and you have version 0.4.0 installed on your system. The open_gem gem (which you are perhaps not even using, but it’s being auto-loaded anyway by rubygems) requires launchy ~> 0.3.5 (meaning, 0.3.5 or 0.3.7), but because it’s loaded outside of Bundler, when Bundler runs and calculates your dependencies, it does not take this into account and simply records version 0.4.0 in your Gemfile.lock. And then when you try to load your app or gem, it balks because 0.3.5 or 0.3.7 has already been loaded by open_gems.

The “obvious” solution is to fix your app to require launchy ~> 0.3.5 as well so it won’t try to load version 0.4.0, but once open_gem gets fixed to work with version 0.4.0, you will just have this problem the other way around, with open_gem loading version 0.4.0, and your app trying to load 0.3.7.

Uninstalling launchy 0.4.0 from your system won’t work either, because Bundler will simply reinstall it when you rerun bundle install (even after you’ve deleted your Gemfile.lock).

For me, the only way to solve this problem was to uninstall open_gem:

1
sudo gem uninstall open_gem

It will also tell you about breaking dependencies – in my case, I’ve had to uninstall guard beforehand.

Now open_gem does not get loaded anymore, and requiring launchy 0.4.0 works fine again.