在Rails中弹出更新后无法运行迁移

我在运行任何迁移时遇到错误:

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' 

所以通过一些谷歌搜索我运行捆绑更新弹簧 ,它解决了上述错误,我能够删除/添加迁移。 再次,如果我运行rake db:migrate ,我收到错误:

 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 ' Tasks: TOP => db:migrate 

请帮我。

运行bundle update并更新Spring后,运行控制台时出现以下错误:

 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 

我按照这个Github问题中的建议运行了:

 spring stop 

这为我解决了这个问题。

尝试在您的终端中运行“捆绑更新”,然后像往常一样再次尝试“rails console” – 我有同样的问题,运行捆绑更新首先为我修复它!

运行:ps aux | grep spring,然后杀死spring过程。

它对我有用。

我有一个类似的问题试图在我的docker容器外运行rails命令。

在我的情况下,我的Gemfile.lock文件说使用Spring(1.3.4),但错误消息说我的服务器运行的是1.3.5版本。 用bundle exec添加我的命令也没有任何区别。 通过运行

gem list | grep spring

我注意到我安装了多个版本。 我跑了之后

gem uninstall spring -v '1.3.5'

并再次bundle ,它完美地工作。

谁知道,我可能在某个时候需要其他项目的新版本。

发生这种情况是因为项目的某个依赖项是Spring的旧版本,而不是系统上安装的版本:

 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) 

处理此问题的正确方法是将bundle exec到您的命令中,如错误消息所示。 请看下面:

运行可执行文件时,始终使用bundle exec [command]。 从捆绑包文档中引用:在某些情况下,如果可执行文件恰好安装在您的系统中并且不会引入任何与您的捆绑包冲突的gem,则运行不带bundle exec的可执行文件可能会起作用。 然而,这是不可靠的,并且是相当痛苦的根源。

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

运行bundle update可能会导致其他一些问题 如果第二个错误仍然存​​在,您可能希望从版本控制恢复到旧的Gemfile

停止弹簧服务器

 spring stop