[英]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.