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

Heroku and webpacker v3.0.0 #739

Closed
vavgustov opened this issue Sep 1, 2017 · 32 comments

Comments

@vavgustov
Copy link

commented Sep 1, 2017

Heroku can't precompile assets with webpacker v3.0.0 but v.2.0.0 worked ok. It's because .bin/webpack doesn't exist:

➜  wb_test git:(master) heroku run rake assets:precompile
Running rake assets:precompile on ⬢ guarded-fortress-96119... up, run.9848 (Free)
yarn install v0.22.0
[1/4] Resolving packages...
success Already up-to-date.
Done in 1.81s.
Webpacker is installed 🎉 🍰
Using /app/config/webpacker.yml file for setting up webpack paths
Compiling…
Compilation failed:

./bin/webpack:26:in `exec': No such file or directory - /app/node_modules/.bin/webpack (Errno::ENOENT)
	from ./bin/webpack:26:in `block in <main>'
	from ./bin/webpack:25:in `chdir'
	from ./bin/webpack:25:in `<main>'

Content of /app/node_modules/.bin/:

~/node_modules/.bin $ ls
webpack-dev-server

Seems yarn v0.22.0 doesn't install bins for nested dependencies (in this case for @rails/webpacker). So if I add webpack as dependency then it works. It seems more like heroku/yarn issue but wanted to let you know.

@renchap

This comment has been minimized.

Copy link
Contributor

commented Sep 1, 2017

See #727

Webpacker 3.0 requires Yarn >= 0.25.2

@vavgustov

This comment has been minimized.

Copy link
Author

commented Sep 1, 2017

yes on my local machine with yarn v0.27.5 it works good. Seems heroku need some time to upgrade yarn version.

@renchap

This comment has been minimized.

Copy link
Contributor

commented Sep 1, 2017

Looks like a PR is needed in the Ruby buildpack to change it: https://github.com/heroku/heroku-buildpack-ruby/blob/78eefa66b96fd04b4738ad8ed66d9bd038324064/lib/language_pack/helpers/nodebin.rb#L21

I suggest you open an issue on this repo, the maintainers are quite responsive.

@vavgustov vavgustov referenced this issue Sep 1, 2017
@javan

This comment has been minimized.

Copy link
Member

commented Sep 1, 2017

I just opened #740, which adds a yarn requirement to package.json's "engines" section. Wonder if the buildpack could read / respect that somehow?

@gauravtiwari

This comment has been minimized.

Copy link
Member

commented Sep 1, 2017

Yeah heroku respects the engines requirement - https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version, will take a look at the PR now and we can merge 👍

@javan

This comment has been minimized.

Copy link
Member

commented Sep 1, 2017

I don't know if that'll work for an engines requirement from a dependency. Might only be for your app's package.json .

@gauravtiwari

This comment has been minimized.

Copy link
Member

commented Sep 1, 2017

screen shot 2017-09-01 at 15 35 04

BTW just deployed an app to heroku and seems to pull in correct yarn version

@WoH

This comment has been minimized.

Copy link
Contributor

commented Sep 1, 2017

@gauravtiwari It seems like you are using multiple (node + ruby) buildpacks.
People affected might be the ones only using the ruby buildpack.

@javan

This comment has been minimized.

Copy link
Member

commented Sep 1, 2017

If you need a temporary workaround, you can update your app's bin/webpack to use yarn run:

--- a/bin/webpack
+++ b/bin/webpack
@@ -20,7 +20,7 @@ unless File.exist?(WEBPACK_CONFIG)
 end
 
 env = { "NODE_PATH" => NODE_MODULES_PATH.shellescape }
-cmd = [ "#{NODE_MODULES_PATH}/.bin/webpack", "--config", WEBPACK_CONFIG ] + ARGV
+cmd = [ "yarn", "run", "webpack", "--config", WEBPACK_CONFIG ] + ARGV
@gauravtiwari

This comment has been minimized.

Copy link
Member

commented Sep 1, 2017

@WoH Oh yes, can confirm - since it's hardcoded. I guess the easiest fix would be to use both ruby and node js buildpack together and that way you don't need to modify anything for now 👍

heroku buildpacks:add heroku/nodejs
heroku buildpacks:add heroku/ruby
@gauravtiwari

This comment has been minimized.

Copy link
Member

commented Sep 1, 2017

@johnrees

This comment has been minimized.

Copy link

commented Sep 5, 2017

@gauravtiwari heroku buildpacks:set will overwrite any previous buildpack(s) with the single buildpack you specify. I think the 'safe' way to run these commands would be -

heroku buildpacks:add heroku/nodejs
heroku buildpacks:add heroku/ruby

Note, it seems that order is important. heroku buildpacks should return heroku/nodejs BEFORE heroku/ruby

heroku buildpacks:clear will remove all buildpacks if you want to add them again in order. So if you just wanted to do all these steps in one go you could also run -

heroku buildpacks:set heroku/nodejs
heroku buildpacks:add heroku/ruby

If for some reason the above doesn't work alone I'm also including

"engines": {
  "yarn": ">= 0.25.2"
}

in my package.json which heroku/nodejs seems to honour during the deployment, although it shouldn't be necessary (I'm including other engines in there too).

@caseyprovost

This comment has been minimized.

Copy link

commented Sep 5, 2017

@vavgustov I believe you should be all set here now. I am using webpacker 3 with vue 2 and rails 5.1 on Heroku just swimmingly :) Feel free to reach out if you are still having issues and maybe I can help you out.

Helpful hints:

  • Follow @johnrees advice above ^^, those buildpacks are important
  • Upgrade brew and then Yarn
  • run bin/yarn locally after upgrading
  • commit any changes
  • deploy to heroku
@vavgustov

This comment has been minimized.

Copy link
Author

commented Sep 5, 2017

@caseyprovost thanks, yes I use solution with node buildpack and found it optimal while heroku works on ruby buildpack improvements. I guess they will add support for engines section for ruby buildpack or at least upgrade yarn.

From my side I would recommend these links for those who have troubles with node + ruby buildpacks:

@kylefox

This comment has been minimized.

Copy link

commented Sep 6, 2017

Just wanted to add that @johnrees's solution worked for me. I ran these commands and the next deploy worked 👍

heroku buildpacks:clear
heroku buildpacks:set heroku/nodejs
heroku buildpacks:add heroku/ruby
@gauravtiwari

This comment has been minimized.

Copy link
Member

commented Sep 6, 2017

@johnrees thanks 💯 👍

@schneems

This comment has been minimized.

Copy link
Member

commented Sep 13, 2017

Sorry for the delay responding here.

You can also do a heroku buildpacks:add heroku/nodejs -i 1 to set nodejs first.

Upgrading the system version of Yarn to v1.0.2 would resolve the issue. Any problems doing that?

schneems added a commit to heroku/heroku-buildpack-ruby that referenced this issue Sep 13, 2017

@gauravtiwari

This comment has been minimized.

Copy link
Member

commented Sep 14, 2017

@schneems Thanks, that should work 👍 💯

@casiodk

This comment has been minimized.

Copy link

commented Sep 14, 2017

heroku buildpacks:add heroku/nodejs -i 1 is the proper command

@antwonlee

This comment has been minimized.

Copy link

commented Sep 18, 2017

Thank you! 👍 💯

@kofronpi

This comment has been minimized.

Copy link

commented Sep 26, 2017

Is it mandatory to fiddle with the heroku buildpacks or is it a temporary fix ?

@gauravtiwari

This comment has been minimized.

Copy link
Member

commented Sep 26, 2017

Until this PR is merged: heroku/heroku-buildpack-ruby#620

schneems added a commit to heroku/heroku-buildpack-ruby that referenced this issue Sep 26, 2017

@schneems

This comment has been minimized.

Copy link
Member

commented Sep 26, 2017

I just merged in yarn 1.0.2 into the master branch of the buildpack. If there's no regressions or issues reported then i'll deploy it shortly. In the mean time use the heroku/nodejs buildpack.

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

vishaltelangre added a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017

Enable heroku review apps (#36)
* Remove sqlite3 gem as it isn't supported on Heroku

* Add staging environment to database.yml

* Fix: Not a git repository (or any parent up to mount point /app)

* Copy example database.yml.postgresql before running db:setup

* The "db:setup" setup task isn't supported

It causes following errors as the "db:reset" subtask cannot be run on Heroku.

FATAL:  permission denied for database "postgres"
DETAIL:  User does not have CONNECT privilege.

* Fix: Missing  for 'staging' environment

* Don't force SSL in staging environment

* Add staging environment config in "config/webpacker.yml"

* Try 'webpacker:compile' task in postdeploy hook

* Changes in config/webpacker.yml

* Add 'nodejs' buildback (Ref: rails/webpacker#739)

* Cleanup

monfresh added a commit to codeforamerica/ohana-web-search that referenced this issue Apr 4, 2018

Add Heroku nodejs buildpack
**Why**: After upgrading to the latest webpacker, assets failed to compile on Heroku. This issue says you need to add the nodejs buildpack: rails/webpacker#739

I also removed unnecessary items from app.json.

monfresh added a commit to codeforamerica/ohana-web-search that referenced this issue Apr 4, 2018

Add Heroku nodejs buildpack
**Why**: After upgrading to the latest webpacker, assets failed to
compile on Heroku. This issue says you need to add the nodejs buildpack:
rails/webpacker#739

Make sure the nodejs buildpack comes before the ruby one.

I also removed unnecessary items from app.json.

monfresh added a commit to codeforamerica/ohana-web-search that referenced this issue Apr 4, 2018

Add Heroku nodejs buildpack to app.json
**Why**: After upgrading to the latest webpacker, assets failed to
compile on Heroku. This issue says you need to add the nodejs buildpack:
rails/webpacker#739

Make sure the nodejs buildpack comes before the ruby one.
For existing apps, this can be done like so:
heroku buildpacks:add heroku/nodejs -i 1 -a your_app_name

I also removed unnecessary items from app.json.

monfresh added a commit to codeforamerica/ohana-web-search that referenced this issue Apr 4, 2018

Add Heroku nodejs buildpack to app.json
**Why**: After upgrading to the latest webpacker, assets failed to
compile on Heroku. This issue says you need to add the nodejs buildpack:
rails/webpacker#739

Make sure the nodejs buildpack comes before the ruby one.
For existing apps, this can be done like so:
heroku buildpacks:add heroku/nodejs -i 1 -a your_app_name

I also removed unnecessary items from app.json.
@sambecker

This comment has been minimized.

Copy link

commented Jul 24, 2018

FWIW heroku buildpacks:add heroku/nodejs -i 1 didn't properly reorder buildpacks for me.

I needed to manually reorder them from the Heroku dashboard in order for my deploy to work.

goodeats added a commit to goodeats/rails-api-react that referenced this issue Aug 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.