我正在尝试预编译我的资产:

rake assets:precompile RAILS_ENV=production bundle exec rake assets:precompile

并得到以下错误:
不知道如何构建任务“bundle”(使用“rake--tasks”查看可用任务列表)
--trace
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke yarn:install (first_time)
** Execute yarn:install
yarn install v1.17.3
[1/4] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 0.04s.
** Execute assets:precompile
rake aborted!
Don't know how to build task 'bundle' (See the list of available tasks with `rake --tasks`)
/Users/anton/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/task_manager.rb:59:in `[]'
/Users/anton/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:159:in `invoke_task'
/Users/anton/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/anton/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:116:in `each'
/Users/anton/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:116:in `block in top_level'
/Users/anton/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:125:in `run_with_threads'
/Users/anton/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:110:in `top_level'
/Users/anton/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:83:in `block in run'
/Users/anton/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/anton/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-12.3.3/lib/rake/application.rb:80:in `run'
/Users/anton/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-12.3.3/exe/rake:27:in `<top (required)>'
/Users/anton/.rbenv/versions/2.6.3/bin/rake:22:in `load'
/Users/anton/.rbenv/versions/2.6.3/bin/rake:22:in `<main>'

如何解决这个问题?我试着更新我的gems,重新安装所有东西,添加了gem 'rake',但仍然得到相同的错误。非常感谢你的帮助。
Rails版本:~> 5.1.6

最佳答案

您似乎混淆了您的命令,因此您试图将两个命令作为一个调用。
看来,你实际上只是想说:

RAILS_ENV=production bundle exec rake assets:precompile

使用最初使用的命令,您将尝试调用名为assets:precompilebundleexecrake和再次assets:precompile的rake任务。由于没有名为bundle的rake任务,因此得到了引用的错误。

关于ruby-on-rails - 不知道如何构建任务“捆绑”-Ruby on Rails,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57375653/

10-16 16:06