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
Closed

Heroku and webpacker v3.0.0 #739

vavgustov opened this issue Sep 1, 2017 · 32 comments

Comments

@vavgustov
Copy link

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
Copy link
Contributor

renchap commented Sep 1, 2017

See #727

Webpacker 3.0 requires Yarn >= 0.25.2

@vavgustov
Copy link
Author

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

@renchap
Copy link
Contributor

renchap 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.

@javan
Copy link
Contributor

javan 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
Copy link
Member

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
Copy link
Contributor

javan 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
Copy link
Member

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
Copy link
Contributor

WoH 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
Copy link
Contributor

javan 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
Copy link
Member

gauravtiwari 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
Copy link
Member

//cc @schneems @hone

@johnrees
Copy link

johnrees 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
Copy link

caseyprovost 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
Copy link
Author

vavgustov 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
Copy link

kylefox 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
Copy link
Member

@johnrees thanks 💯 👍

@schneems
Copy link
Member

schneems 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?

@gauravtiwari
Copy link
Member

@schneems Thanks, that should work 👍 💯

@casiodk
Copy link

casiodk commented Sep 14, 2017

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

@sicktastic
Copy link

Thank you! 👍 💯

@kofronpi
Copy link

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

@gauravtiwari
Copy link
Member

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
Copy link
Member

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
vishaltelangre pushed a commit to bigbinary/apisnapshot that referenced this issue Nov 30, 2017
* 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
**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
**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
**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
**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
Copy link

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.

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