s12chung
s12chung

Reputation: 1768

"bundle exec spring" not working with rbenv?

Why doesn't bundle exec spring work?

I am already calling bundle exec and that returns an error. I am okay calling bundle exec all the time. (This is the solution to the possible duplicate question).

I will not update my Gemfile via bundle update spring or uninstall a version of spring to make this work. I should not be forced to change my gem installation.

bundle binstubs spring isn't working either.

steve-air:finalcloud main$ spring -v
Spring version 1.3.5
steve-air:finalcloud main$ bundle exec spring -v
Spring version 1.3.4
steve-air:finalcloud main$ bundle exec spring
/Users/main/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:34:in `block in setup': You have already activated spring 1.3.5, but your Gemfile requires spring 1.3.4. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.7/lib/bundler/runtime.rb:19:in `setup'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.7/lib/bundler.rb:122:in `setup'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.9.7/lib/bundler/setup.rb:8:in `<top (required)>'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.5/lib/spring/commands.rb:33:in `<module:Spring>'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.5/lib/spring/commands.rb:4:in `<top (required)>'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.5/lib/spring/server.rb:9:in `<top (required)>'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
  from /Users/main/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'

To replicate:

  1. Have Ruby installed with rebenv.
  2. Uninstall all Spring gems.
  3. Install a lower version of Spring (such as 1.3.4).
  4. Make a new Rails app.
  5. Install a higher version of Spring (1.3.5 seems to have disappeared, but I replicated with 1.3.6).
  6. Follow the steps in my command line above.

Upvotes: 9

Views: 3673

Answers (3)

Kannan S
Kannan S

Reputation: 2489

Just uninstall the older version of the spring gem

gem uninstall spring

Upvotes: 1

Mircea
Mircea

Reputation: 10566

After a bit of exploration there seem there could be a couple of things in play here:

  1. system installed gems via bundler installed gems and the special behavior rails has
  2. generated binstubs at rvm and bundle level
  3. weird behavior in Spring 1.3.5

The root cause of the issue seems to be https://github.com/rails/spring/issues/295 which was fixed in 1.3.6. See: https://github.com/rails/spring/blob/master/CHANGELOG.md#136

Sadly, it turns out you cannot workaround this with the constraints the author specified in the question.

Upvotes: 7

Tim Moore
Tim Moore

Reputation: 9472

This is a bug in Spring that has been fixed in version 1.3.6.

i will not update my Gemfile (via bundle update spring) or uninstall a version of spring to make this work---i should not be forced to change my gem installation.

Unfortunately, these are the only known workarounds in versions earlier than 1.3.6.

Upvotes: 3

Related Questions