我正在使用capistrano部署一个rails 7.0.4.3应用。当我运行cap production deploy
时,服务在此步骤停止:deploy:assets:precompile 01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
产生这个错误
01 rake aborted!
01 Sprockets::FileNotFound: couldn't find file 'trix/dist/trix' with type 'text/css'
01 Checked in these paths:
01 /home/deploy/dynamic_performance/releases/20230530181802/app/assets/config
01 /home/deploy/dynamic_performance/releases/20230530181802/app/assets/images
01 /home/deploy/dynamic_performance/releases/20230530181802/app/assets/stylesheets
01 /home/deploy/dynamic_performance/shared/bundle/ruby/3.2.0/gems/tailwindcss-rails-0.3.3/app/assets/fonts
01 /home/deploy/dynamic_performance/shared/bundle/ruby/3.2.0/gems/tailwindcss-rails-0.3.3/app/assets/stylesheets
01 /home/deploy/dynamic_performance/shared/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/app/assets/javascripts
01 /home/deploy/dynamic_performance/shared/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/app/assets/stylesheets
01 /home/deploy/dynamic_performance/shared/bundle/ruby/3.2.0/gems/actioncable-7.0.4.3/app/assets/javascripts
01 /home/deploy/dynamic_performance/shared/bundle/ruby/3.2.0/gems/activestorage-7.0.4.3/app/assets/javascripts
01 /home/deploy/dynamic_performance/shared/bundle/ruby/3.2.0/gems/actionview-7.0.4.3/lib/assets/compiled
01 /home/deploy/dynamic_performance/shared/bundle/ruby/3.2.0/gems/turbolinks-source-5.2.0/lib/assets/javascripts
.... truncated for brevity
我读过其他帖子说运行yarn install --check-files
和rails action_text:install
,但这没有帮助。当我在本地运行rails s
时,操作文本工作正常。如何修复此错误并正确编译资产?
1条答案
按热度按时间mspsb9vt1#
发生在我身上的事情,这就是引擎盖下发生的事情。升级到Rails 7.0后,任务
rake assets:precompile
不会执行yarn install
。这就是为什么Sprockets在node_modules
文件夹中找不到依赖项的原因。您可以使用以下代码解决此问题。我想这是Rails 7的预期行为。