简体   繁体   English

rake db:命令显示 NoMethodError:nil:NilClass 错误的未定义方法“chomp”

[英]rake db: commands show NoMethodError: undefined method `chomp' for nil:NilClass error

When rake db: commands are executed, it shows an error当 rake db: 命令执行时,它显示错误

warning: parser/current is loading parser/ruby26, which recognizes
warning: 2.6.7-compliant syntax, but you are running 2.6.2.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
C:/Ruby26-x64/bin/rake: No such file or directory - which yarn
rake aborted!
NoMethodError: undefined method `chomp' for nil:NilClass
C:/.../config/environment.rb:5:in `<main>'
Tasks: TOP => db:migrate => db:load_config => environment
(See full trace by running task with --trace)

This happens on a Windows10 machine, but the mac machine is working fine without errors.这发生在 Windows10 机器上,但 mac 机器工作正常,没有错误。 It's a Ruby on rails application.这是 Ruby 轨道应用。 Here's the environment.rb:这是 environment.rb:

# Load the Rails application.
require_relative 'application'

# Initialize the Rails application.
Rails.application.initialize!

Any help would be appreciated.任何帮助,将不胜感激。

Edit: The output of running rake with the --trace flag to see where exactly the NoMethodError was coming from ( rake --trace db:migrate ):编辑:使用 --trace 标志运行 rake 的 output 以查看 NoMethodError 的确切来源( rake --trace db:migrate ):

rake --trace db:migrate
warning: parser/current is loading parser/ruby26, which recognizes
warning: 2.6.7-compliant syntax, but you are running 2.6.2.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
C:/Ruby26-x64/bin/rake: No such file or directory - which yarn
rake aborted!
NoMethodError: undefined method `chomp' for nil:NilClass
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/mjml-rails-4.6.1/lib/mjml.rb:68:in `check_for_yarn_mjml_binary'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/mjml-rails-4.6.1/lib/mjml.rb:44:in `valid_mjml_binary'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/mjml-rails-4.6.1/lib/mjml/railtie.rb:13:in `block in <class:Railtie>'

Answering my own question:回答我自己的问题:

My team and I, on the investigation, found out that the versions specified in the Gemfile and Gemfile.lock were different.我和我的团队在调查中发现 Gemfile 和 Gemfile.lock 中指定的版本不同。 The versions had got upgraded explicitly, so we'd had to load a predefined Gemfile.lock, and bringing gems on the same version solved the issue.版本已显式升级,因此我们必须加载预定义的 Gemfile.lock,并在同一版本上添加 gem 解决了这个问题。 So, for anyone else facing this issue, please check the versions (of the Gemfile and Gemfile.lock).因此,对于其他面临此问题的人,请检查版本(Gemfile 和 Gemfile.lock)。

PS. PS。 To much of our surprise, it didn't actually have anything to do with the database config.令我们惊讶的是,它实际上与数据库配置没有任何关系。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 rake db:migrate命令后发生错误:rake中止了! NoMethodError:未定义的方法&#39;accept&#39;为nil:NilClass - Error after rake db:migrate command: rake aborted! NoMethodError: undefined method `accept' for nil:NilClass Rails 4-rake db:seed NoMethodError:nil:NilClass的未定义方法“名称” - Rails 4 - rake db:seed NoMethodError: undefined method `name' for nil:NilClass rake db:create为nil:NilClass错误提供了未定义的方法&#39;[]&#39; - rake db:create gives undefined method `[]' for nil:NilClass error Ruby on Rails 5:NoMethodError:耙db:migrate时,nil:NilClass的未定义方法`+&#39; - Ruby on Rails 5: NoMethodError: undefined method `+' for nil:NilClass when rake db:migrate 为nil:NilClass获取错误未定义方法`[]&#39;(NoMethodError) - Getting error undefined method `[]' for nil:NilClass (NoMethodError) Ruby未定义方法`[]&#39;表示nil:NilClass(NoMethodError)错误 - Ruby undefined method `[]' for nil:NilClass (NoMethodError) error rake 资产:使用 NoMethodError 进行预编译:nil:NilClass 的未定义方法“tr” - rake assets:precompile with NoMethodError: undefined method `tr' for nil:NilClass 倾斜测试准备:NoMethodError:nil:NilClass的未定义方法“ []” - rake test prepare: NoMethodError: undefined method `[]' for nil:NilClass NoMethodError:nil:NilClass的未定义方法“ []” - NoMethodError: undefined method `[]' for nil:NilClass NoMethodError:nil:NilClass的未定义方法&#39;&#39; - NoMethodError: undefined method '' for nil:NilClass
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM