rails / webpacker

Use Webpack to manage app-like JavaScript modules in Rails
MIT License
5.3k stars 1.47k forks source link

Compiles fail with no output #395

Closed schneems closed 7 years ago

schneems commented 7 years ago

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?

bajalovic commented 7 years ago

From Gemfile

gem 'webpacker', github: "rails/webpacker"

And from Gemfile.lock

GIT
  remote: https://github.com/rails/webpacker.git
  revision: a4297678fba34791f5618ebbff9d00cfcb92547e
  specs:
    webpacker (2.0)
      activesupport (>= 4.2)
      multi_json (~> 1.2)
      railties (>= 4.2)
gauravtiwari commented 7 years ago

And there is nothing in the log why it failed? Any error message? Anything after yarn run v0.24.5?

bajalovic commented 7 years ago

Nope, just that..

bajalovic commented 7 years ago

Executing webpack on my machine went fine.. Am I missing some depedency on the server?

I installed node 6.10.3, yarn 0.24.5,... its Ubuntu 16.04

gauravtiwari commented 7 years ago
  "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.

bajalovic commented 7 years ago

Hey @gauravtiwari , now I'm getting following error

      01 Webpacker is installed πŸŽ‰ 🍰
      01
      01 Using /home/deploy/apps/habitat/releases/20170602181402/config/webpacker.yml file for setting up webpack paths
      01
      01 [Webpacker] Compiling assets πŸŽ‰
      01
      01 [Webpacker] Compilation Failed
      01
      01 yarn run v0.24.5
      01 $ "/home/deploy/apps/habitat/releases/20170602181402/node_modules/.bin/webpack" --config /home/deploy/apps/habitat/releases/20170602181402/config/webpack/production.js
      01 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
      01
      01 Killed
      01 error Command failed with exit code 137.
      01
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host 104.236.10.248: rake exit status: 1
rake stdout: RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too,
you can ignore these warnings with 'rvm rvmrc warning ignore /home/deploy/apps/habitat/releases/20170602181402/Gemfile'.
To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'.

yarn install v0.24.5
[1/4] Resolving packages...
success Already up-to-date.
$ npm rebuild node-sass

> node-sass@4.5.3 install /home/deploy/apps/habitat/releases/20170602181402/node_modules/node-sass
> node scripts/install.js

node-sass build Binary found at /home/deploy/apps/habitat/releases/20170602181402/node_modules/node-sass/vendor/linux-x64-48/binding.node

> node-sass@4.5.3 postinstall /home/deploy/apps/habitat/releases/20170602181402/node_modules/node-sass
> node scripts/build.js

Binary found at /home/deploy/apps/habitat/releases/20170602181402/node_modules/node-sass/vendor/linux-x64-48/binding.node
Testing binary
Binary is fine
node-sass@4.5.3 /home/deploy/apps/habitat/releases/20170602181402/node_modules/node-sass
Done in 7.01s.
Webpacker is installed πŸŽ‰ 🍰
Using /home/deploy/apps/habitat/releases/20170602181402/config/webpacker.yml file for setting up webpack paths
[Webpacker] Compiling assets πŸŽ‰
[Webpacker] Compilation Failed
yarn run v0.24.5
$ "/home/deploy/apps/habitat/releases/20170602181402/node_modules/.bin/webpack" --config /home/deploy/apps/habitat/releases/20170602181402/config/webpack/production.js
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Killed
error Command failed with exit code 137.

rake stderr: Nothing written

SSHKit::Command::Failed: rake exit status: 1
rake stdout: RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too,
you can ignore these warnings with 'rvm rvmrc warning ignore /home/deploy/apps/habitat/releases/20170602181402/Gemfile'.
To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'.

yarn install v0.24.5
[1/4] Resolving packages...
success Already up-to-date.
$ npm rebuild node-sass

> node-sass@4.5.3 install /home/deploy/apps/habitat/releases/20170602181402/node_modules/node-sass
> node scripts/install.js

node-sass build Binary found at /home/deploy/apps/habitat/releases/20170602181402/node_modules/node-sass/vendor/linux-x64-48/binding.node

> node-sass@4.5.3 postinstall /home/deploy/apps/habitat/releases/20170602181402/node_modules/node-sass
> node scripts/build.js

Binary found at /home/deploy/apps/habitat/releases/20170602181402/node_modules/node-sass/vendor/linux-x64-48/binding.node
Testing binary
Binary is fine
node-sass@4.5.3 /home/deploy/apps/habitat/releases/20170602181402/node_modules/node-sass
Done in 7.01s.
Webpacker is installed πŸŽ‰ 🍰
Using /home/deploy/apps/habitat/releases/20170602181402/config/webpacker.yml file for setting up webpack paths
[Webpacker] Compiling assets πŸŽ‰
[Webpacker] Compilation Failed
yarn run v0.24.5
$ "/home/deploy/apps/habitat/releases/20170602181402/node_modules/.bin/webpack" --config /home/deploy/apps/habitat/releases/20170602181402/config/webpack/production.js
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Killed
error Command failed with exit code 137.

rake stderr: Nothing written

Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing on host 104.236.10.248: rake exit status: 1
rake stdout: RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too,
you can ignore these warnings with 'rvm rvmrc warning ignore /home/deploy/apps/habitat/releases/20170602181402/Gemfile'.
To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'.

yarn install v0.24.5
[1/4] Resolving packages...
success Already up-to-date.
$ npm rebuild node-sass

> node-sass@4.5.3 install /home/deploy/apps/habitat/releases/20170602181402/node_modules/node-sass
> node scripts/install.js

node-sass build Binary found at /home/deploy/apps/habitat/releases/20170602181402/node_modules/node-sass/vendor/linux-x64-48/binding.node

> node-sass@4.5.3 postinstall /home/deploy/apps/habitat/releases/20170602181402/node_modules/node-sass
> node scripts/build.js

Binary found at /home/deploy/apps/habitat/releases/20170602181402/node_modules/node-sass/vendor/linux-x64-48/binding.node
Testing binary
Binary is fine
node-sass@4.5.3 /home/deploy/apps/habitat/releases/20170602181402/node_modules/node-sass
Done in 7.01s.
Webpacker is installed πŸŽ‰ 🍰
Using /home/deploy/apps/habitat/releases/20170602181402/config/webpacker.yml file for setting up webpack paths
[Webpacker] Compiling assets πŸŽ‰
[Webpacker] Compilation Failed
yarn run v0.24.5
$ "/home/deploy/apps/habitat/releases/20170602181402/node_modules/.bin/webpack" --config /home/deploy/apps/habitat/releases/20170602181402/config/webpack/production.js
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Killed
error Command failed with exit code 137.

rake stderr: Nothing written

** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:

 DEBUG [c6892875]

 DEBUG [c6892875]

 DEBUG [c6892875]   Done in 7.01s.

 DEBUG [c6892875]

 DEBUG [c6892875]   Webpacker is installed πŸŽ‰ 🍰

 DEBUG [c6892875]

 DEBUG [c6892875]   Using /home/deploy/apps/habitat/releases/20170602181402/config/webpacker.yml file for setting up webpack paths

 DEBUG [c6892875]

 DEBUG [c6892875]   [Webpacker] Compiling assets πŸŽ‰

 DEBUG [c6892875]

 DEBUG [c6892875]   [Webpacker] Compilation Failed

 DEBUG [c6892875]

yarn run v0.24.5

$ "/home/deploy/apps/habitat/releases/20170602181402/node_modules/.bin/webpack" --config /home/deploy/apps/habitat/releases/20170602181402/config/webpack/production.js

info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Killed

error Command failed with exit code 137.
flybayer commented 7 years ago

@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.

bajalovic commented 7 years ago

@flybayer I got new droplet on DigitalOcean, with 512MB Ram/1 CPU, 20GB SSD.. This is too small for compiling?

flybayer commented 7 years ago

@bajalovic yeah, it could be. Node takes a LOT of memory. You can run the top process while compiling to see how much it's taxing your system, but this is almost certainly the issue.

bajalovic commented 7 years ago

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...

shaun965 commented 7 years ago

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?

zachmalone commented 7 years ago

@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.

paulodeon commented 6 years ago

It was a memory issue for me as well

yunixon commented 5 years ago

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]