rails 6 webpacker in production: rake assets:precompile fails
Asked Answered
O

4

5

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?

Oloroso answered 13/2, 2020 at 20:36 Comment(1)
Can you paste manifest.js code with the questionEntrap
E
2

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!

Entrap answered 13/2, 2020 at 20:56 Comment(1)
thanks for your help. I've updated my question with the code from my manifest.js file. Im not sure what you mean by 'formatting problem' can you give me some more info?Oloroso
D
8

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.

Dodds answered 15/12, 2020 at 19:46 Comment(2)
This did it for me after I moved stylesheets un the js/packs folder for webpacker to work properlyGastrotomy
I created app/images/.keep (since in my case it was failing for static assets, not css).Kordofanian
B
3

Adding a .keep file in both the images and javascript folders fixed it for me.

Bonheur answered 30/3, 2021 at 9:18 Comment(0)
E
2

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!

Entrap answered 13/2, 2020 at 20:56 Comment(1)
thanks for your help. I've updated my question with the code from my manifest.js file. Im not sure what you mean by 'formatting problem' can you give me some more info?Oloroso
C
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

City answered 13/2, 2020 at 23:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.