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

webpacker:compile executes before or after assets:precompile #169

Closed
hone opened this issue Mar 11, 2017 · 36 comments
Closed

webpacker:compile executes before or after assets:precompile #169

hone opened this issue Mar 11, 2017 · 36 comments

Comments

@hone
Copy link

hone commented Mar 11, 2017

Hello, I'm working on getting webpacker supported on Heroku. I see this warning when running rake assets:precompile on an app.

I, [2017-03-11T00:08:01.980134 #1188]  INFO -- : Didn't find any digests file at /tmp/build_e690a85412228cbd44c858dcaab50841/public/packs/digests.json. You must first compile the packs via rails webpacker:compile

Is webpacker:compile meant to run after or before assets:precompile? The code and comment suggest this isn't the case.

@gauravtiwari
Copy link
Member

gauravtiwari commented Mar 11, 2017

@hone This is OK, because the digests.json is produced after the webpacker:compile is run so, it will log that message anyway regardless whether it's runs before or after. In this case, it runs after assets are compiled. Here is the source - https://github.com/rails/webpacker/blob/master/lib/webpacker/digests.rb#L38

@schneems
Copy link
Member

@gauravtiwari we need to not error or warn when people are using the software correctly. Otherwise when 5.1 is released there will be dozens or hundreds of issues opened about the warning and it will be a bad experience for the end user. We also need to verify the current software is correct.

@gauravtiwari
Copy link
Member

@schneems I agree :) the warning is actually pointless now but perhaps, earlier it was needed. I think this will go away in stable 1.0 as there are some additions on way that will change the way this is handled. Perhaps someone from webpacker/rails core team can verify.

@schneems
Copy link
Member

I have commit to Rails. Terence posted because the behavior was unclear. I posted because it is still unclear.

@ytbryan
Copy link
Contributor

ytbryan commented Mar 14, 2017

@schneems thanks for pointing this out. I think @gauravtiwari has acknowledged with agreement. Making it "go away" is a common goal.

It's not the first time we tried addressing this warning. It was briefly mentioned at #116 too

Moving forward, we can remove/replace that warning if it's no longer relevant (Is this true?) Anyone, please feel free to make suggestion so that a PR can be made to fix this.

Just to add on, I tried deploying a new rails with --webpack=vue --database=postgresql and heroku buildpacks:set heroku/nodejs --index 1 and heroku buildpacks:set heroku/ruby --index 2. Deployment works but app crashed without any hint. Perhaps there are other critical issues to be fixed here? @gauravtiwari have you deployed to heroku recently? successful?

@gauravtiwari
Copy link
Member

gauravtiwari commented Mar 14, 2017

@ytbryan No don't think this is relevant anymore and I will get rid of it in #153, with new manifest generation plugin.

For heroku I think the vue option added sass loader, which needs node-sass, but I think that's installed on heroku. If you manually add node sass and add post install hook under scripts to rebuild node-sass, within your package.json I think it will deploy fine.

Let me know if this works.

@gauravtiwari
Copy link
Member

Ohh the deployment works?did you tailed the logs - heroku logs -t to see why it's failing?

@ytbryan
Copy link
Contributor

ytbryan commented Mar 14, 2017

Sorry, didn't had time to investigate just now. But seems this might be the fix http://stackoverflow.com/a/15693371/388280 (I might have missed it, can we set the port to fix Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch ?)

I think node-sass is already included -> https://github.com/rails/webpacker/blob/master/lib/tasks/installers/vue.rake#L43

@gauravtiwari Do you have a working repo that you used to deploy to heroku on github?

2017-03-14T03:14:10.291163+00:00 app[web.1]: => Booting Puma
2017-03-14T03:14:10.291176+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-03-14T03:14:10.291175+00:00 app[web.1]: => Rails 5.1.0.beta1 application starting in production on http://localhost:56335
2017-03-14T03:14:10.291177+00:00 app[web.1]: Puma starting in single mode...
2017-03-14T03:14:10.291181+00:00 app[web.1]: * Version 3.8.1 (ruby 2.2.6-p396), codename: Sassy Salamander
2017-03-14T03:14:10.291182+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-03-14T03:14:10.291184+00:00 app[web.1]: * Environment: production
2017-03-14T03:14:10.291315+00:00 app[web.1]: * Listening on tcp://localhost:56335
2017-03-14T03:14:10.292146+00:00 app[web.1]: Use Ctrl-C to stop
2017-03-14T03:15:05.427193+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-03-14T03:15:05.427293+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-03-14T03:15:05.547843+00:00 heroku[web.1]: Process exited with status 137
2017-03-14T03:15:05.561391+00:00 heroku[web.1]: State changed from starting to crashed

@schneems
Copy link
Member

Here's a bare bones example app I made https://github.com/schneems/rails51_webpacker

We don't have yarn installed on Heroku yet for Ruby apps, you have to use @hone's brach or wait a day or two and use master. That being said, I would expect the deploy to fail instead of the server failing to boot.

@d3chapma
Copy link

@schneems Just to be clear, Rails apps with webpacker do not have a straightforward method to deploy? Not sure what branch you are referring to when you say @hone's branch. Any insight?

@schneems
Copy link
Member

For clarity @hone and I work for Heroku. We are the Ruby buildpack maintainers. We want to make sure that webpacker and Rails 5.1 play nice on heroku. When I say "branch" I am referring to a branch of the buildpack that installs yarn heroku/heroku-buildpack-ruby#540.

@gauravtiwari
Copy link
Member

gauravtiwari commented Mar 15, 2017

@ytbryan Ohh, you seem to binding to localhost. It should be web: bundle exec puma -p $PORT or with rails server specify -b option with 0.0.0.0

Here is one, but using the latest feature branch - https://github.com/gauravtiwari/webpacker-demo-app

@gauravtiwari
Copy link
Member

@schneems Just to confirm this warning will go away once #153 is merged.

@schneems
Copy link
Member

Awesome, BTW we released support for Yarn https://devcenter.heroku.com/changelog-items/1114

Also that puma not booting problem is a bug in Rails. It's fixed on master but i documented a way around it in my changelog entry.

@gauravtiwari
Copy link
Member

That's awesome, no need of node build pack anymore. Great, actually I saw this behaviour a while ago but didn't realise it could be a bug. Thank you :)

@ytbryan
Copy link
Contributor

ytbryan commented Mar 17, 2017

I think it still require buildpack https://devcenter.heroku.com/articles/ruby-support#installed-binaries

Great, thanks Richard!

@gauravtiwari
Copy link
Member

gauravtiwari commented Mar 17, 2017

@schneems Just noticed while deploying a webpacker app that, buildpack installs yarn, but doesn't run yarn install afterwards like bundle install. Could you please test this with a new rails app with webpacker?

screen shot 2017-03-17 at 07 47 30

@hone
Copy link
Author

hone commented Mar 17, 2017

@gauravtiwari I used this app as a test. Does webpacker not call yarn install anymore? This is what I see:

remote: -----> Installing node-v6.10.0-linux-x64
remote: -----> Installing yarn-0.22.0
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        I, [2017-03-15T20:09:53.526602 #413]  INFO -- : Didn't find any digests file at /tmp/build_ea8c8655b3a069f74edc0cbe81285af7/public/packs/digests.json. You must first compile the packs via rails webpacker:compile
remote:        yarn install v0.22.0
remote:        [1/4] Resolving packages...
remote:        [2/4] Fetching packages...
remote:        warning fsevents@1.1.1: The platform "linux" is incompatible with this module.
remote:        info "fsevents@1.1.1" is an optional dependency and failed compatibility check. Excluding it from installation.
remote:        [3/4] Linking dependencies...
remote:        [4/4] Building fresh packages...
remote:        Done in 25.22s.
remote:        (node:869) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56
remote:        parseQuery() will be replaced with getOptions() in the next major version of loader-utils.
remote:        Compiled digests for all packs in /tmp/build_ea8c8655b3a069f74edc0cbe81285af7/public/packs/digests.json:
remote:        {"application":"application-52d19136d5660afd39af.js"}
remote:        Asset precompilation completed (28.33s)
remote:        Cleaning assets
remote:        Running: rake assets:clean

@gauravtiwari
Copy link
Member

@hone Nope, internally webpacker doesn't call yarn install, just enhances assets:precompile with webpacker:compile. I guess this app is also using nodejs buildpack. Nodejs buildpack does run yarn install if used alongside ruby. Perhaps, it makes sense to add this to the buildpack instead, if used with webpacker?

@hone
Copy link
Author

hone commented Mar 18, 2017

@gauravtiwari I just tested a fresh Rails 5.1 app and yarn install was run inside the assets:precompile task. On none of these apps have I set the node buildpack b/c that would defeat the whole point. /cc @guilleiguaran

@gauravtiwari
Copy link
Member

The screenshot I posted before do not use any buildpack, just simple git push heroku master

@hone
Copy link
Author

hone commented Mar 18, 2017

is that code available somewhere?

@gauravtiwari
Copy link
Member

Ahh right. Let me try again.

@hone
Copy link
Author

hone commented Mar 18, 2017

👍 thanks for your help and testing this before RC1 lands ❤️

@gauravtiwari
Copy link
Member

No worries @hone ❤️ This is the one I am deploying. Actually someone else had another issue whilst deploying to heroku, so this is a fork that fixes it - https://github.com/gauravtiwari/webpacker-erb-heroku. This is what I get -

screen shot 2017-03-18 at 07 38 28

screen shot 2017-03-18 at 07 39 05

screen shot 2017-03-18 at 07 39 12

@gauravtiwari
Copy link
Member

Obviously when I set the build-packs manually then all works -

screen shot 2017-03-18 at 07 41 25

screen shot 2017-03-18 at 07 41 41

screen shot 2017-03-18 at 07 42 26

@hone
Copy link
Author

hone commented Mar 18, 2017

@gauravtiwari weird. i wonder if there's something in rails 5.1 that runs yarn install? I'll have to investigate later or have @schneems do it. It's almost 3am here :(

@gauravtiwari
Copy link
Member

@hone Ohh yes, my bad I should have suspected that. It's definitely 5.1 - rails/rails@b1c08d8

@hone
Copy link
Author

hone commented Mar 18, 2017

@gauravtiwari 👍 mystery solved. That being said, it would be nice to probably make this work for webpacker standalone or we should pull that from Rails into here?

@gauravtiwari
Copy link
Member

@hone Ohh, that's too late. Alright, I won't pester you, talk later 👍

@gauravtiwari
Copy link
Member

@hone I think it makes sense to add a standalone yarn installer for webpacker to make it compatible with other Rails version. Seems like that's the only missing piece.

@hone
Copy link
Author

hone commented Mar 20, 2017 via email

@gauravtiwari
Copy link
Member

Yes, that's the plan. I can make a PR once #153 is merged.

@gauravtiwari
Copy link
Member

Btw @hone @schneems Should we also install npm as well if webpacker is used alongside yarn on Heroku? Seems like, if folks are using node with yarn, they might need or use npm in some cases. For ex - npm rebuild node-sass

@gauravtiwari
Copy link
Member

@hone this can be closed. #153 is merged

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

No branches or pull requests

6 participants