Webpacker: Webpacker and mina releases problem

Created on 30 Sep 2017  ·  10Comments  ·  Source: rails/webpacker

I’m getting the following error, until I do RAILS_ENV=production bundle exec rake assets:precompile from the project folder and reboot ubuntu

ActionView::Template::Error (Webpacker can't find dash.js in path_blah/releases/52/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
   unless you are using the `webpack -w` or the webpack-dev-server.
2. Webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your Webpack configuration is not creating a manifest.
Your manifest contains:
{
}
):

The thing is that mina skips assets precompilation step if I don’t make any changes to my assets and set a new release folder.

I’ve just tried to do mina deploy without doing any edits to my project and it finished successfully.
But again, I’m still getting the error that I shared above ActionView::Template::Error (Webpacker can't find dash.js…)

```
Bundle complete! 42 Gemfile dependencies, 94 gems now installed.
Gems in the groups development and test were not installed.
Bundled gems are installed into ./vendor/bundle.
-----> DB migrations unchanged; skipping DB migration
-----> Skipping asset precompilation
-----> Cleaning up old releases (keeping 5)
path_blah/tmp/build-15067693715817
-----> Deploy finished
-----> Building
-----> Moving build to path_blah/releases/54
-----> Build finished
-----> Launching
-----> Updating the path_blah/current symlink
/path_blah/current
-----> Done. Deployed version 54

All 10 comments

If you are compiling assets locally, then you would need to make sure packs directory is not ignored in .gitignore or you could run NODE_ENV=production bundle exec rails webpacker:compile during deploy like assets:precompile. Please see docs: https://github.com/rails/webpacker/blob/master/docs/deployment.md

Thanks. It works if I precompile locally and remove packs from gitignore.

But what if I don't want to precompile locally?
NODE_ENV=production RAILS_ENV=production bundle exec rails webpacker:compile finishes successfully but the problem still persists.

With packs inside gitignore,
running the command from mina:

    invoke :'rails:db_migrate'
    invoke :'rails:assets_precompile'
    command %{NODE_ENV=production RAILS_ENV=production bundle exec rails webpacker:compile}
    invoke :'deploy:cleanup'

gives the following output:

       ** Invoke webpacker:check_binstubs (first_time)
       ** Execute webpacker:check_binstubs
       ** Execute webpacker:verify_install
       Webpacker is installed 🎉 🍰
       Using path_to_app/tmp/build-150677837319530/config/webpacker.yml file for setting up webpack paths
       ** Invoke environment (first_time)
       ** Execute environment
       ** Execute webpacker:compile
       Compiling…
       Compilation failed:

       ./bin/webpack:26:in `exec': No such file or directory - path_to_app/tmp/build-150677837319530/node_modules/.bin/webpack (Errno::ENOENT)
        from ./bin/webpack:26:in `block in <main>'
        from ./bin/webpack:25:in `chdir'
        from ./bin/webpack:25:in `<main>'

The following seems to be working but it's smilar to force recompile :/

command %{NODE_ENV=production RAILS_ENV=production bundle exec rails assets:precompile}

 ./bin/webpack:26:in `exec': No such file or directory - path_to_app/tmp/build-150677837319530/node_modules/.bin/webpack (Errno::ENOENT)
        from ./bin/webpack:26:in `block in <main>'
        from ./bin/webpack:25:in `chdir'
        from ./bin/webpack:25:in `<main>'

You have to run yarn install prior to webpacker:compile.

This task bundle exec rails assets:precompile takes care of everything but you would need to make sure the sprockets assets are not compiled locally otherwise it will skip like the first log you have pasted.

-----> Skipping asset precompilation

You can build a custom workflow by running yarn install prior to webpacker:compile, that way sprockets compilation cache will work.

something like that:

command %{yarn install}
command %{bundle exec rails webpacker:compile}

But keep in mind it may compile twice in case assets:precompile is also run. There is a pending issue to skip webpacker compile during sprockets precompilation. May be we can provide a flag to turn off webapacker:compile through assets:precompile, that way people can build their own custom workflows like above.

Does the above solves your problem?

Yes, thank you :) I run it with env vars and it works.

    command %{yarn install}
    command %{NODE_ENV=production RAILS_ENV=production bundle exec rails webpacker:compile}

Great 👍 Just NODE_ENV=production is enough though, don't need RAILS_ENV

it fails without RAILS_ENV :D

rails aborted!
       LoadError: Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile
       /
...

Ahh right makes sense, add it back please :D Sorry about that 👍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

suhomozgy-andrey picture suhomozgy-andrey  ·  3Comments

ytbryan picture ytbryan  ·  3Comments

iChip picture iChip  ·  3Comments

FrankFang picture FrankFang  ·  3Comments

itay-grudev picture itay-grudev  ·  3Comments