13

I am facing a error when I run any migration as:

raj@notebook-pc:~/Desktop/Projects/invoicemanagement$ rails g migration RemoveDescriptionOfGoodsFromInvoiceDetails description_of_goods:string
Warning: You're using Rubygems 1.8.23 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
/var/lib/gems/1.9.1/gems/bundler-1.9.0/lib/bundler/runtime.rb:34:in `block in setup': 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)
    from /var/lib/gems/1.9.1/gems/bundler-1.9.0/lib/bundler/runtime.rb:19:in `setup'

    ** 11 stack trace lines skipped **

    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'

So with some googling I run bundle update spring, which solved the above error, and I am able to remove/add migrations. Again if I run rake db:migrate, I am getting error as:

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

undefined method `to_sym' for nil:NilClass/var/lib/gems/1.9.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/schema_definitions.rb:216:in `column'

    ** 33 stack trace lines skipped **

/var/lib/gems/1.9.1/gems/activerecord-4.1.4/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate

Please help me.

klenwell
  • 6,978
  • 4
  • 45
  • 84
sachin god
  • 685
  • 2
  • 12
  • 29

6 Answers6

27

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.

klenwell
  • 6,978
  • 4
  • 45
  • 84
3

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!

TABISH KHAN
  • 1,553
  • 1
  • 19
  • 32
  • 3
    I would say that bundle update is typically not a great idea, unless you are sure that all your gems can update without breaking things. – stevenspiel Apr 19 '15 at 00:32
2

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

It worked for me.

smdev
  • 45
  • 5
2

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.

Caleb
  • 188
  • 4
1

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.

Drenmi
  • 8,492
  • 4
  • 42
  • 51
  • Are you getting the first or the second error. The second one is because of `bundle update`, and won't be fixed by using `bundle exec`. To solve the second one, you need to revert your code to a point before you did `bundle update` from your version control. – Drenmi Mar 23 '15 at 05:06
  • I am doing the same, when I re-enter the add migration command, i am getting this 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.3.2, SERVER: 1.3.3`x. – sachin god Mar 23 '15 at 05:09
  • I see. Is this a private project, or do you have a repository where I can have a look at it? – Drenmi Mar 23 '15 at 05:28
  • Actually you cannot access this project. If you require any part of the code, i will paste it. – sachin god Mar 23 '15 at 05:38
0

Stop the spring server

spring stop