rails 6 webpacker in production: rake assets:precompile fails

故事扮演 提交于 2021-01-07 21:40:53

问题


I have a typical rails 6.0.2 app set up on a production server and I'm using git hooks to deploy the app. When I try to run: rails assets:precompile I get the following error:

rake aborted!
Sprockets::ArgumentError: link_directory argument must be a directory
/home/user/myapp/app/assets/config/manifest.js:2

Here is the manifest.js file

//= link_tree ../images
//= link_directory ../stylesheets .css

I cant figure out what Im doing wrong. Unless I'm mistaken, doesn't webpacker replace sprockets?


回答1:


In manifest.js, your error tells that in manifest.js line 2, link_directory argument must be a directory, and not a file. It should probably look like this

//= link_directory ../stylesheets .css

If you notice there is gap between stylesheets and .css, it means that link all the css files from stylesheets directory, there must be some formatting problem in your code. Fix it and it should work!




回答2:


double check all the asset folder for an empt .keep file

common culprit could be images folder

this post may also help out

require_tree argument must be a directory in a Rails 5 upgraded app




回答3:


For anyone else who got this error, I simply added a directory in assets, called stylesheets, and added a file .keep within it. That fixed my problem.



来源:https://stackoverflow.com/questions/60216082/rails-6-webpacker-in-production-rake-assetsprecompile-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!