webpacker: Heroku error: didn't find any digests file && ActionView::Template::Error (Can't find hello_react)

Step to reproduce:

  1. rails new myapp -d postgresql
  2. add webpacker to gemfile gem 'webpacker', :git => "https://github.com/rails/webpacker.git"
  3. bundle install
  4. rails webpacker:install
  5. rails webpacker:install:vue
  6. rails webpacker:compile
  7. use the <%= javascript_pack_tag ‘hello_vue’ %>
  8. test on localhost (It works*)
  9. heroku create webpacker-demos-123
  10. git remote add <heroku-git-url>
  11. push to heroku (don’t work*)

ERROR (didn’t find any digests file)

remote: Using webpacker 1.0 from https://github.com/rails/webpacker.git (at master@8f584dd) remote: Bundle complete! 16 Gemfile dependencies, 54 gems now installed. remote: Gems in the groups development and test were not installed. remote: Bundled gems are installed into ./vendor/bundle. remote: Bundle completed (3.32s) remote: Cleaning up the bundler cache. remote: -----> Detecting rake tasks remote: -----> Preparing app for Rails asset pipeline remote: Running: rake assets:precompile remote: I, [2017-02-25T01:31:43.346954 #437] INFO – : Didn’t find any digests file at /tmp/build_a7f573d5e29cf560546c07e2807f75aa/public/packs/digests.json. You must first compile the packs via rails webpacker:compile remote: sh: 1: ./node_modules/webpack/bin/webpack.js: not found 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 webpacker-demos. remote: To https://git.heroku.com/webpacker-demos.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to ‘https://git.heroku.com/webpacker-demos.git’ pushing to origin/master

To fix the above error, turns out I need to rake assets:precompile instead of rails webpacker:compile. Should the error message be modified?

Once the assets are precompiled. Pushing to heroku works but leads to another error ( ActionView::Template::Error (Can’t find hello_react))

2017-02-25T01:41:14.753037+00:00 heroku[router]: at=info method=GET path=“/” host=webpacker-demos.herokuapp.com request_id=44e6cff5-5bbc-46d9-b84c-ced9704e12c3 fwd=“138.75.142.195” dyno=web.1 connect=0ms service=35ms status=500 bytes=1669 2017-02-25T01:41:14.730223+00:00 app[web.1]: I, [2017-02-25T01:41:14.730082 #4] INFO – : [44e6cff5-5bbc-46d9-b84c-ced9704e12c3] Started GET “/” for 138.75.142.195 at 2017-02-25 01:41:14 +0000 2017-02-25T01:41:14.734543+00:00 app[web.1]: I, [2017-02-25T01:41:14.734419 #4] INFO – : [44e6cff5-5bbc-46d9-b84c-ced9704e12c3] Processing by FrontpagesController#index as HTML 2017-02-25T01:41:14.750165+00:00 app[web.1]: I, [2017-02-25T01:41:14.750028 #4] INFO – : [44e6cff5-5bbc-46d9-b84c-ced9704e12c3] Rendering frontpages/index.html.erb within layouts/application 2017-02-25T01:41:14.752474+00:00 app[web.1]: I, [2017-02-25T01:41:14.752379 #4] INFO – : [44e6cff5-5bbc-46d9-b84c-ced9704e12c3] Rendered frontpages/index.html.erb within layouts/application (2.1ms) 2017-02-25T01:41:14.752779+00:00 app[web.1]: I, [2017-02-25T01:41:14.752711 #4] INFO – : [44e6cff5-5bbc-46d9-b84c-ced9704e12c3] Completed 500 Internal Server Error in 18ms 2017-02-25T01:41:14.754036+00:00 app[web.1]: F, [2017-02-25T01:41:14.753928 #4] FATAL – : [44e6cff5-5bbc-46d9-b84c-ced9704e12c3]
2017-02-25T01:41:14.754105+00:00 app[web.1]: F, [2017-02-25T01:41:14.754040 #4] FATAL – : [44e6cff5-5bbc-46d9-b84c-ced9704e12c3] ActionView::Template::Error (Can’t find hello_react-e57d9d18a79d866e81fe in #<Webpacker::Digests:0x007f46977f3110 @path=#Pathname:/app/public/packs/digests.json, @digests={}>): 2017-02-25T01:41:14.754371+00:00 app[web.1]: F, [2017-02-25T01:41:14.754297 #4] FATAL – : [44e6cff5-5bbc-46d9-b84c-ced9704e12c3] 1: <\h1>Hello world! 2017-02-25T01:41:14.754373+00:00 app[web.1]: [44e6cff5-5bbc-46d9-b84c-ced9704e12c3] 2: 2017-02-25T01:41:14.754375+00:00 app[web.1]: [44e6cff5-5bbc-46d9-b84c-ced9704e12c3] 3: <%# javascript_pack_tag ‘hello_vue-819142dc19b77ca48015’ %> 2017-02-25T01:41:14.754376+00:00 app[web.1]: [44e6cff5-5bbc-46d9-b84c-ced9704e12c3] 4: <%= javascript_pack_tag ‘hello_react-e57d9d18a79d866e81fe’ %> 2017-02-25T01:41:14.754426+00:00 app[web.1]: F, [2017-02-25T01:41:14.754370 #4] FATAL – : [44e6cff5-5bbc-46d9-b84c-ced9704e12c3]
2017-02-25T01:41:14.754492+00:00 app[web.1]: F, [2017-02-25T01:41:14.754436 #4] FATAL – : [44e6cff5-5bbc-46d9-b84c-ced9704e12c3] app/views/frontpages/index.html.erb:4:in `_app_views_frontpages_index_html_erb___4234948065689000601_69970601556860’

Is this related to existing issues? I’m still digging

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 21 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Nice! okay for @gauravtiwari to close this ticket?

@sealocal everything moved to root folder so, now it’s usual setup for yarn. https://github.com/rails/webpacker/pull/101

@ytbryan this works - https://webpacker-vue.herokuapp.com/ and code here - https://github.com/gauravtiwari/webpacker-vue

The only additions are - adding correct buildpacks for heroku

heroku buildpacks:set heroku/nodejs --index 1
heroku buildpacks:set heroku/ruby --index 2

And add a Procfile to run webpack dev server + configuration in development.rb

and moving all the devDependencies except webpack dev server to dependencies block. Strangely, yarn doesn’t seem to install them on production. There are many issues filed on Github in same regards, here is one - https://github.com/yarnpkg/yarn/issues/2739

@sealocal Rails 5.0.1

@gauravtiwari https://github.com/ytbryan/webpacker-demos

gonna be away for the next two days, will look at all these info and dig into it when i’m back.