Skip to content

Hook into asset:pipeline silently fails on heroku #28

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

Closed
phawk opened this issue Sep 26, 2021 · 7 comments · Fixed by #31
Closed

Hook into asset:pipeline silently fails on heroku #28

phawk opened this issue Sep 26, 2021 · 7 comments · Fixed by #31

Comments

@phawk
Copy link
Contributor

phawk commented Sep 26, 2021

Using this with a fresh Rails 6.1 app, when deploying to Heroku using the default 'heroku/ruby' build pack, the asset pipeline hooks fail silently stating:

Yarn executable was not detected in the system.
Download Yarn at https://yarnpkg.com/en/docs/install

The app continues to deploy and then the follow 500 error happens when you try to load pages.

ActionView::Template::Error (The asset "application.css" is not present in the asset pipeline.

SSH’ing into the dyno and there are no files in the app/assets/builds directory.

All running fine using bin/dev locally. I’m not sure how complex it is, but it would be nice if it could fail hard when yarn is not installed.

To fix the issue adding heroku/nodejs as the primary buildpack makes it all work.

I know this is a heroku issue, in terms of making it work out of the box like it did with webpacker, but I think failing loudly might help diagnose the issue easier.

P.s. This gem is awesome! So much easier to work with than webpack and along with the jsbundling-rails + esbuild its so fast. Keep up the great work!!!!

Full logs of the failing heroku build:

-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/ruby
-----> Ruby app detected
-----> Installing bundler 2.2.21
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-3.0.0
-----> Installing dependencies using bundler 2.2.21
       Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
       Using rake 13.0.6
       Using concurrent-ruby 1.1.9
       Using i18n 1.8.10
       Using minitest 5.14.4
       Using tzinfo 2.0.4
       Using zeitwerk 2.4.2
       Using activesupport 6.1.4.1
       Using builder 3.2.4
       Using erubi 1.10.0
       Using racc 1.5.2
       Using nokogiri 1.12.4 (x86_64-linux)
       Using rails-dom-testing 2.0.3
       Using crass 1.0.6
       Using loofah 2.12.0
       Using rails-html-sanitizer 1.4.2
       Using actionview 6.1.4.1
       Using rack 2.2.3
       Using rack-test 1.1.0
       Using actionpack 6.1.4.1
       Using nio4r 2.5.8
       Using websocket-extensions 0.1.5
       Using websocket-driver 0.7.5
       Using actioncable 6.1.4.1
       Using globalid 0.5.2
       Using activejob 6.1.4.1
       Using activemodel 6.1.4.1
       Using activerecord 6.1.4.1
       Using marcel 1.0.2
       Using mini_mime 1.1.1
       Using activestorage 6.1.4.1
       Using mail 2.7.1
       Using actionmailbox 6.1.4.1
       Using actionmailer 6.1.4.1
       Using actiontext 6.1.4.1
       Using ast 2.4.2
       Using msgpack 1.4.2
       Using bootsnap 1.9.1
       Using bundler 2.2.21
       Using method_source 1.0.0
       Using thor 1.1.0
       Using railties 6.1.4.1
       Using cssbundling-rails 0.2.2
       Using faraday-em_http 1.0.0
       Using faraday-em_synchrony 1.0.0
       Using faraday-excon 1.1.0
       Using faraday-httpclient 1.0.1
       Using faraday-net_http 1.0.1
       Using faraday-net_http_persistent 1.2.0
       Using faraday-patron 1.0.0
       Using faraday-rack 1.0.0
       Using multipart-post 2.1.1
       Using ruby2_keywords 0.0.5
       Using faraday 1.8.0
       Using sprockets 4.0.2
       Using sprockets-rails 3.2.2
       Using rails 6.1.4.1
       Using stimulus-rails 0.6.0
       Using turbo-rails 0.8.1
       Using hotwire-rails 0.1.3
       Using jsbundling-rails 0.1.7
       Using parallel 1.21.0
       Using parser 3.0.2.0
       Using pg 1.2.3
       Using puma 5.5.0
       Using rainbow 3.0.0
       Using redis 4.4.0
       Using regexp_parser 2.1.1
       Using rexml 3.2.5
       Using rubocop-ast 1.11.0
       Using ruby-progressbar 1.11.0
       Using unicode-display_width 2.1.0
       Using rubocop 1.21.0
       Using rubocop-rails 2.12.2
       Using rubocop-rspec 2.5.0
       Using rubocop-shopify 2.2.0
       Using sentry-ruby-core 4.7.3
       Using sentry-rails 4.7.3
       Using sentry-ruby 4.7.3
       Bundle complete! 25 Gemfile dependencies, 78 gems now installed.
       Gems in the groups 'development' and 'test' were not installed.
       Bundled gems are installed into `./vendor/bundle`
       Bundle completed (0.56s)
       Cleaning up the bundler cache.
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       Yarn executable was not detected in the system.
       Download Yarn at https://yarnpkg.com/en/docs/install
       Yarn executable was not detected in the system.
       Download Yarn at https://yarnpkg.com/en/docs/install
       Yarn executable was not detected in the system.
       Download Yarn at https://yarnpkg.com/en/docs/install
       Yarn executable was not detected in the system.
       Download Yarn at https://yarnpkg.com/en/docs/install
       Asset precompilation completed (2.44s)
       Cleaning assets
       Running: rake assets:clean
-----> Detecting rails configuration
###### WARNING:
       There is a more recent Ruby version available for you to use:
       
       3.0.2
       
       The latest version will include security and bug fixes. We always recommend
       running the latest version of your minor release.
       
       Please upgrade your Ruby version.
       
       For all available Ruby versions see:
         https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
-----> Discovering process types
       Procfile declares types     -> web
       Default types for buildpack -> console, rake
-----> Compressing...
       Done: 39M
-----> Launching...
       Released v10
@dhh
Copy link
Member

dhh commented Sep 26, 2021

Cc @schneems

@bbonamin
Copy link

bbonamin commented Sep 27, 2021 via email

@phawk
Copy link
Contributor Author

phawk commented Sep 27, 2021

Hi @bbonamin, I know, that’s not the point of my issue, it’s that when yarn is not available the asset:precompile task continues to run and doesn’t error, despite the fact it doesn't build your bundles, and therefore you get a successful deploy, but a broken application.

@bbonamin
Copy link

bbonamin commented Sep 27, 2021 via email

@dhh
Copy link
Member

dhh commented Sep 27, 2021

I'd be happy to see a PR where assets:precompile explodes if it can't run properly 👍

@phawk
Copy link
Contributor Author

phawk commented Sep 27, 2021

I’ll see what I can do!

@schneems
Copy link
Member

I'm tracking this issue here heroku/heroku-buildpack-ruby#1202

In the short term workaround you need to:

$ heroku buildpacks:add --index=1 heroku/nodejs

That will install node and yarn for your app.

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 a pull request may close this issue.

4 participants