Client-server version mismatch when multiple versions of spring installed for the current Ruby
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
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...
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...
Try to stop server and other and then run:
spring stop
then start everything you need.
@stgeneral thanks it worked.
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.
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.
It's works for me too.
spring stop
Viola it worked for me too spent the whole night on this single line...
spring stop :+1:
Thanks. Wish I had seen this earlier. spring stop worked for me as well.
It works, thanks
spring stop shrug
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
spring stop works :+1:
spring stop :+1:
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'
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.
spring stop works
spring stop works for me too! :+1:
Maybe someone can try
bundle update spring
if
spring stop
does not work. Thanks.