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

rake db: commands show NoMethodError: undefined method `chomp' for nil:NilClass 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)

这发生在 Windows10 machine 上,但 mac machine 工作正常,没有错误。这是 rails 上的 Ruby 应用程序。 这是 environment.rb:

# Load the Rails application.
require_relative 'application'

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

如有任何帮助,我们将不胜感激。

编辑: 运行 rake 的输出带有 --trace 标志以查看 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>'

回答我自己的问题:

我和我的团队在调查中发现 Gemfile 和 Gemfile.lock 中指定的版本不同。版本已经明确升级,所以我们不得不加载一个预定义的 Gemfile.lock,并且在相同版本上引入 gem 解决了这个问题。 因此,对于遇到此问题的任何其他人,请检查版本(Gemfile 和 Gemfile.lock)。

PS。令我们惊讶的是,它实际上与数据库配置没有任何关系。