spring icon indicating copy to clipboard operation
spring copied to clipboard

Client-server version mismatch when multiple versions of spring installed for the current Ruby

Open suan opened this issue 12 years ago • 47 comments

I've noticed that when using multiple versions of Spring in the app's current Ruby, I get that error. This is a common occurrence because we have many apps on the same Ruby version, but possibly using dfferent versions of Spring. Even doing bundle exec bin/rails c or bundle exec spring rails c results in the same behavior.

$ bin/rails c
...
...
There is a version mismatch between the spring client and the server.
You should restart the server and make sure to use the same version.

CLIENT: 1.0.0, SERVER: 1.1.2

suan avatar Apr 22 '14 17:04 suan

I had the same issue and what I did : I comment the gem spring and than I run the command rails generate devise:install and than I went back to my gem file and I get the gem spring again and run the bundle install...

Mikbel avatar May 13 '14 23:05 Mikbel

However when I run rails generate devise:views give me the same issue : There is a version mismatch between the spring client and the server. You should restart the server and make sure to use the same version. CLIENT: 1.1.3, SERVER: 1.1.2 so I'm gonna skip it for now and keep going with my app...

Mikbel avatar May 13 '14 23:05 Mikbel

Try to stop server and other and then run:

spring stop

then start everything you need.

stgeneral avatar May 14 '14 07:05 stgeneral

@stgeneral thanks it worked.

prathe avatar May 14 '14 19:05 prathe

spring stop worked for me too - thanks! I don't even know what spring is, but it was stopping me from programming for a morning.

kevinmccaughey avatar May 16 '14 08:05 kevinmccaughey

Did you reproduce this issue with Spring 1.1? There were significant changes in that version. Please reopen if it's relevant to the latest spring version.

jonleighton avatar Jul 07 '14 21:07 jonleighton

It's works for me too.

delef avatar Feb 16 '15 19:02 delef

spring stop Viola it worked for me too spent the whole night on this single line...

danieldizzy avatar Feb 17 '15 07:02 danieldizzy

spring stop :+1:

DemitryT avatar Feb 19 '15 13:02 DemitryT

Thanks. Wish I had seen this earlier. spring stop worked for me as well.

stephenbaidu avatar Feb 24 '15 22:02 stephenbaidu

It works, thanks

julioalucero avatar Feb 27 '15 18:02 julioalucero

spring stop shrug

baird avatar Mar 01 '15 20:03 baird

I have the same issue:

Error:[rake --tasks] There is a version mismatch between the spring client and the server.
You should restart the server and make sure to use the same version.
CLIENT: 1.3.3, SERVER: 1.2.0

Spring stop is not helped: Spring is not running

lancedikson avatar Mar 15 '15 19:03 lancedikson

spring stop works :+1:

sql-runner avatar Apr 03 '15 19:04 sql-runner

spring stop :+1:

mhtremblay avatar Apr 13 '15 19:04 mhtremblay

spring stop does not work for me when going from a newer version of Spring to an older version (in my case, we updated Spring on a branch and I had to work on a fix on master).

The problem is that the Spring client is starting the wrong version of the server here: https://github.com/rails/spring/blob/f18afb8c5ac951b7553c812482d491001b1425a8/lib/spring/client/run.rb#L68

That spawns a Ruby process that requires spring/server, but it doesn't do anything to lock the version of the gem that it loads, so the newest version will be required by default. Ordinarily, this job would be done by Bundler, but Spring tries to bootstrap without loading Bundler.

After the subprocess starts, Bundler is later setup, which tries to restrict the load path to the older Spring version in Gemfile.lock, but by this point it is too late and so it reports an error:

/Users/tmoore/.gem/ruby/2.1.6/gems/bundler-1.9.4/lib/bundler/runtime.rb:34:in `block in setup': You have already activated spring 1.3.4, but your Gemfile requires spring 1.3.3. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
    from /Users/tmoore/.gem/ruby/2.1.6/gems/bundler-1.9.4/lib/bundler/runtime.rb:19:in `setup'
    from /Users/tmoore/.gem/ruby/2.1.6/gems/bundler-1.9.4/lib/bundler.rb:122:in `setup'
    from /Users/tmoore/.gem/ruby/2.1.6/gems/bundler-1.9.4/lib/bundler/setup.rb:8:in `<top (required)>'
    from /Users/tmoore/.rubies/ruby-2.1.6/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
    from /Users/tmoore/.rubies/ruby-2.1.6/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
    from /Users/tmoore/.rubies/ruby-2.1.6/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
    from /Users/tmoore/Projects/cultureamp/murmur/.bundle/ruby/2.1.0/gems/spring-1.3.4/lib/spring/commands.rb:33:in `<module:Spring>'
    from /Users/tmoore/Projects/cultureamp/murmur/.bundle/ruby/2.1.0/gems/spring-1.3.4/lib/spring/commands.rb:4:in `<top (required)>'
    from /Users/tmoore/.rubies/ruby-2.1.6/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/tmoore/.rubies/ruby-2.1.6/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/tmoore/Projects/cultureamp/murmur/.bundle/ruby/2.1.0/gems/spring-1.3.4/lib/spring/server.rb:9:in `<top (required)>'
    from /Users/tmoore/.rubies/ruby-2.1.6/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
    from /Users/tmoore/.rubies/ruby-2.1.6/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
    from /Users/tmoore/.rubies/ruby-2.1.6/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'

TimMoore avatar Apr 15 '15 03:04 TimMoore

I found I could fix the problem by editing the server spawn code linked above in client/run.rb like this:

        pid = Process.spawn(
          gem_env,
          "ruby",
          "-e", "gem 'spring', '#{Spring::VERSION}'; require 'spring/server'; Spring::Server.boot"
        )

@jonleighton do you see any problems with that approach? I'm happy to put together a pull request.

TimMoore avatar Apr 15 '15 03:04 TimMoore

spring stop works

momwhocode avatar Apr 15 '15 06:04 momwhocode

spring stop works for me too! :+1:

Vibhuti avatar Apr 16 '15 21:04 Vibhuti

Maybe someone can try

bundle update spring

if

spring stop

does not work. Thanks.

bobzhen avatar Apr 21 '15 09:04 bobzhen