Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid empty error message when assets:precompile fail #911

Conversation

choznerol
Copy link

@choznerol choznerol commented Aug 29, 2019

Currently when a build fail at assets:precompile,error message is not visible unless matching the 2 specified cases.

For example, in following log only 'Precompiling assets failed.' was output.

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.6.3
-----> Installing dependencies using bundler 1.15.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x64-mingw32, x86-mswin32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32 java`.
       Using rake 12.3.2
       Using concurrent-ruby 1.1.5
       Using i18n 1.6.0
       ...
       Using title 0.0.7
       Using uglifier 4.1.20
       Using webpacker 4.0.7
       Bundle complete! 63 Gemfile dependencies, 143 gems now installed.
       Gems in the groups development and test were not installed.
       Bundled gems are installed into `./vendor/bundle`
       Removing bundler (1.15.2)
       Bundle completed (0.64s)
       Cleaning up the bundler cache.
       The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x64-mingw32, x86-mswin32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32 java`.
-----> Installing node-v10.15.3-linux-x64
-----> Installing yarn-v1.16.0
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       W, [2019-08-29T05:45:20.284064 #274]  WARN -- sentry: ** [Raven] You are running on Heroku but haven't enabled Dyno Metadata. For Sentry's release detection to work correctly, please run `heroku labs:enable runtime-dyno-metadata`
       I, [2019-08-29T05:45:20.284182 #274]  INFO -- sentry: ** [Raven] Raven 2.11.0 configured not to capture errors: DSN not set
       Note: Google::Cloud::Logging is disabled because it failed to authorize with the service. (Could not load the default credentials. Browse to
       https://developers.google.com/accounts/docs/application-default-credentials
       for more information
       ) Falling back to the default Rails logger.
       yarn install v1.16.0
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       info [email protected]: The platform "linux" is incompatible with this module.
       info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
       [3/4] Linking dependencies...
       warning "@hahow/hh-classroom > [email protected]" has unmet peer dependency "moment@^2.24.0".
       warning " > [email protected]" has unmet peer dependency "react-is@>= 16.8.0".
       warning "@hahow/hh-classroom > styled-components > [email protected]" has unmet peer dependency "stylis@^3.5.0".
       ...
       warning " > [email protected]" has unmet peer dependency "@typescript-eslint/[email protected]".
       warning " > [email protected]" has incorrect peer dependency "[email protected]".
       warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0".
       [4/4] Building fresh packages...
       Done in 55.27s.
       I, [2019-08-29T05:46:28.779511 #274]  INFO -- : Writing /tmp/build_cd15716fd0cc5207a3b863fd43cdf76e/public/assets/rails_admin/rails_admin-946c0320e5428d853d62d7ce91c9359a3a8813b61315f0189f4e45347de08c59.js
       I, [2019-08-29T05:46:28.779986 #274]  INFO -- : Writing /tmp/build_cd15716fd0cc5207a3b863fd43cdf76e/public/assets/rails_admin/rails_admin-946c0320e5428d853d62d7ce91c9359a3a8813b61315f0189f4e45347de08c59.js.gz
       I, [2019-08-29T05:46:31.189711 #274]  INFO -- : Writing /tmp/build_cd15716fd0cc5207a3b863fd43cdf76e/public/assets/rails_admin/rails_admin-a5ac3667cda05bcd6fd057c32fa37efbf745b1eddf48577d63afe229cfa43355.css
       ...
       I, [2019-08-29T05:46:36.410783 #274]  INFO -- : Writing /tmp/build_cd15716fd0cc5207a3b863fd43cdf76e/public/assets/actiontext/test/dummy/app/assets/stylesheets/application-5012ecb04079eb015f5aeb648c58f5e6f44dda7226233def08ceae9a8f806be9.css.gz
       I, [2019-08-29T05:46:36.569473 #274]  INFO -- : Writing /tmp/build_cd15716fd0cc5207a3b863fd43cdf76e/public/assets/actiontext/test/dummy/app/javascript/packs/application-1616dbf6c074462ce21c21b4df6b5871ef31f6224e2b4eb647713d06e8c746f2.js
       I, [2019-08-29T05:46:36.570112 #274]  INFO -- : Writing /tmp/build_cd15716fd0cc5207a3b863fd43cdf76e/public/assets/actiontext/test/dummy/app/javascript/packs/application-1616dbf6c074462ce21c21b4df6b5871ef31f6224e2b4eb647713d06e8c746f2.js.gz
       Compiling…
       Compilation failed:
       
 !
 !     Precompiling assets failed.
 !
 !     Push rejected, failed to compile Ruby app.
 !     Push failed

I think it would be helpful for debugging if a fail task fallbacks to print its full error message, when none of the 2 pre-defined error patterns is matched.

@leonelgalan
Copy link

leonelgalan commented Sep 25, 2019

I was having issues precompiling, so decided to try this fork instead of heroku/ruby to see what was wrong: the problem is that it simply "duplicated" the output by printing again everything after Running: rake assets:precompile

This works great, you can test it by adding the buildpack using the HTTPS address of the repo and the branch name after a #:

https://github.com/choznerol/heroku-buildpack-ruby.git#precompile_fail-print-error-output-if-nothing-match

Thanks @choznerol

Update:

For those expecting webpacker errors, this PR is not needed, as long as you add webpack_compile_output: true in your config/webpacker.yml. you should see the output on the original heroku/ruby buildpack

@schneems
Copy link
Contributor

schneems commented Nov 5, 2019

The output is already streamed to STDOUT so if we were to also output that value then there would be duplicate values.

Do you have an app or an example that has an output value that is not already in STDOUT?

For those expecting webpacker errors, this PR is not needed, as long as you add webpack_compile_output: true in your config/webpacker.yml. you should see the output on the original heroku/ruby buildpack

Thanks a ton, I know this comment has helped other users!

@schneems schneems closed this Nov 5, 2019
@choznerol
Copy link
Author

Thanks @leonelgalan ! Indeed webpack_compile_output: true is the actual missing part in my case. Also thanks @schneems for further clarification!

@choznerol choznerol deleted the precompile_fail-print-error-output-if-nothing-match branch November 15, 2019 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants