当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机器上,但Mac机器工作正常,没有错误。这是一个Ruby on Rails应用程序。这是环境。rb:
# Load the Rails application.
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!
型
如果你能帮忙的话,我将不胜感激。
编辑:使用--trace标志运行rake的输出,以查看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>'
型
2条答案
按热度按时间kzmpq1sx1#
回答我自己的问题:
我和我的团队在调查中发现Gemfile和Gemfile.lock中指定的版本是不同的。版本已经明确升级了,所以我们必须加载一个预定义的Gemfile.lock,在同一版本上引入gems解决了这个问题。因此,对于其他遇到此问题的人,请检查(Gemfile和Gemfile.lock的)版本。
让我们大吃一惊的是,它实际上与数据库配置没有任何关系。
7gyucuyw2#
当我在Windows 11上运行Ruby版本2.7.4和命令rake db:migrate ERROR时,我得到了同样的错误:C:/Ruby27-x64/bin/rake:没有这样的文件或目录-yarn rake中止!NoMethodError:undefined method `chomp' for nil:NilClass FIX:安装,使用chocolatey在windows 11从以下链接,https://community.chocolatey.org/packages/which & RUN捆绑安装解决了错误.