webpacker: Compiles fail with no output

From https://github.com/heroku/heroku-buildpack-ruby/issues/562

I’m getting a non-trivial number of people getting compile failures, but with no debug output of any kind. Here’s an example:

remote:        Webpacker is installed 🎉 🍰
remote:        Using /tmp/build_c3975d9e573c1bf0b4e6b532daa48fde/config/webpack/paths.yml file for setting up webpack paths
remote:        Compiling webpacker assets 🎉
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy....
remote: 
remote: !	Push rejected to [my app].

Is there anything else we can do when this happens? Any way to add debug info? Maybe toggle an environment variable for extra logging?

Have you seen silent failures like this before? Any ideas?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 14
  • Comments: 64 (24 by maintainers)

Commits related to this issue

Most upvoted comments

Failed with no output:

NODE_ENV=production RAILS_ENV=production bundle exec rails assets:precompile --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.15.2
warning package.json: No license field
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.7: The platform "linux" is incompatible with this module.
info "fsevents@1.2.7" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > webpack-dev-server@3.2.1" has unmet peer dependency "webpack@^4.0.0".
warning "webpack-dev-server > webpack-dev-middleware@3.6.1" has unmet peer dependency "webpack@^4.0.0".
[4/4] Building fresh packages...
Done in 5.69s.
** Execute assets:precompile
** Invoke webpacker:compile (first_time)
** Invoke webpacker:verify_install (first_time)
** Invoke webpacker:check_node (first_time)
** Execute webpacker:check_node
** Invoke webpacker:check_yarn (first_time)
** Execute webpacker:check_yarn
** Invoke webpacker:check_binstubs (first_time)
** Execute webpacker:check_binstubs
** Execute webpacker:verify_install
** Invoke environment 
** Execute webpacker:compile
Compiling…
Compilation failed:
warning package.json: No license field

Hash: ef8a4c46aefd8a023d3e
Version: webpack 4.29.6
Time: 554ms
Built at: 2019-03-29 14:26:44
                                        Asset       Size  Chunks             Chunk Names
       js/application-24d579ad03023092387c.js   1.02 KiB       0  [emitted]  application
    js/application-24d579ad03023092387c.js.gz  540 bytes          [emitted]  
   js/application-24d579ad03023092387c.js.map   5.05 KiB       0  [emitted]  application
js/application-24d579ad03023092387c.js.map.gz   1.91 KiB          [emitted]  
                                manifest.json  364 bytes          [emitted]  
                             manifest.json.gz  142 bytes          [emitted]  
Entrypoint application = js/application-24d579ad03023092387c.js js/application-24d579ad03023092387c.js.map
[0] ./app/javascript/packs/application.js 514 bytes {0} [built]

I am getting similar issues and have tried related things in this thread.

I have been purging my cache and verything compiles fine when running locally NODE_ENV=production RAILS_ENV=production rails assets:precompile --trace

remote:        Webpacker is installed 🎉 🍰
remote:        Using /tmp/build_91d2b3e82c1066b40277d3fb399e94a1/config/webpacker.yml file for setting up webpack paths
remote:        [Webpacker] Compiling assets 🎉
remote:        error Command failed with exit code 2.
remote:
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote:
remote:  !     Push failed
remote: Verifying deploy...

Is there anyway to find where the error is?

@shaun965 In config/webpack/production.js I set warnings: true for the compress setting of the uglify plugin and ended up getting verbose error logging during the compilation process.

@thisiserik try running assets:precompile locally to see what error you get:

NODE_ENV=production RAILS_ENV=production rails assets:precompile --trace

thanks @flybayer, memory was the issue here. I increased instance, and it worked. I also measured while compiling, it took up to ~800mb of ram…

  "scripts": {
    "postinstall": "npm rebuild node-sass"
  }

Could you add this to your package.json and try deploying again?

Strange that you don’t get any error output.

@schneems Yepp, I have seen it before and most probably it’s related to node-sass binary either not available or corrupted - related to https://github.com/sass/node-sass/issues/1918

One more thing I noticed and mentioned in (https://github.com/rails/webpacker/issues/169#issuecomment-288296033) was that with regular ruby buildpack npm isn’t available alongside yarn. I think it would be useful to have that too on heroku.

"scripts": {
"postinstall": "npm rebuild node-sass"
}

I think this is a bug we need to fix for compile task. Currently we are using a non-standard way to get output from webpack compile task, which is unhelpful for debugging. I started adding js scripts in #264. Perhaps, I can just make a PR with only scripts so it improves the debugging workflow.

@bajalovic I’ve had that killed error before. The problem was not enough system resources. Restart your server and try again. Maybe stop any other running apps as well. If it still fails, upgrade your server.

No worries!

Nice! Yepp that’s another to solve this, totally forgot 👍 Basically the problem is vue-scrollTo has es6 code, which isn’t being compiled by babel-loader since node_modules are ignored. Will add this to README 👍 until we start using es6-aware minifier.

@schneems at the moment if the users need to use npm for anything for ex - npm rebuild node-sass using post-install hook, the npm binary isn’t available on heroku on ruby buildpack with webpacker. It is available in node-js build-pack though. Might make sense to have npm too if heroku has yarn support with webpacker?

BTW, fixed the debugging issue on master so, now compile task will provide much better debug output if assets:precompile fails because of webpacker.

screen shot 2017-05-22 at 16 43 21

screen shot 2017-05-22 at 16 44 42

Ref- #403

Now precompiling is failing every single time regardless of cache state, including the exact code I was using the other week in a brand new dokku app. * scratches head *

Precompiling locally in production mode works flawlessly.

Thanks for filing this, Richard.

@flybayer Which version of webpacker are you using? Master branch? Can I confirm it’s rails 5.1.0 and not 5.1.1? @fuffi Same question to you