Couldn't run migration after spring update in Rails

偶尔善良 提交于 2019-12-03 05:39:19

After running bundle update and updating Spring, I was getting the following error when running the console:

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.4, SERVER: 1.3.3

I followed the recommendations in this Github issue and ran:

spring stop

This fixed the issue for me.

try running "bundle update" in your terminal, then try "rails console" again as usual - i had this same issue , running bundle update first fixed it for me!

Run: ps aux | grep spring, then kill the spring process.

It worked for me.

I had a similar problem trying to run rails commands outside of my docker container.

In my case, my Gemfile.lock file said to use Spring (1.3.4), but the error message said my server was running version 1.3.5. Prepending my command with bundle exec didn't make any difference either. By running

gem list | grep spring

I noticed I had multiple versions installed. After I ran

gem uninstall spring -v '1.3.5'

and bundle again, it worked perfectly.

Who knows, I may have needed the newer version for some other project at some time.

This happens because one of the dependencies of your project is an older version of Spring than is installed on your system:

You have already activated spring 1.3.3, but your Gemfile requires spring 1.3.2. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)

The correct way to deal with this is to prepend bundle exec to your command, as the error message indicates. Please see below:

When running an executable, ALWAYS use bundle exec [command]. Quoting from the bundler documentation: In some cases, running executables without bundle exec may work, if the executable happens to be installed in your system and does not pull in any gems that conflict with your bundle. However, this is unreliable and is the source of considerable pain.

http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/

Running bundle update can cause some other issues. If your second error persists, you might want to revert to your old Gemfile from version control.

Stop the spring server

spring stop
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!