Skip to content

How to avoid multiple yarn install commands on Heroku #130

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
rsanheim opened this issue Aug 24, 2022 · 1 comment · Fixed by #150
Closed

How to avoid multiple yarn install commands on Heroku #130

rsanheim opened this issue Aug 24, 2022 · 1 comment · Fixed by #150

Comments

@rsanheim
Copy link

rsanheim commented Aug 24, 2022

Note: This isn't really a jsbundling-rails issue, but I figured this is going to be fairly common issues as more folks are upgrading Rails / Heroku legacy apps from webpack to jsbundling w/ esbuild or alternative tools.

We are working on converting to esbuild away from webpack / rails-webpacker for a large-ish app that is deployed to Heroku.

So far almost everything is working, but we are seeing multiple calls to yarn install in Heroku deploys now in our esbuild branch. I'm wondering if there is a way to avoid this with Heroku when having both the nodejs and ruby buildpacks installed? The double installs aren't really a problem, but they do clutter up our logs and add time to deployments.

I read through #16, and also scanned through the node and ruby buildpack code, but don't see any clear way to tell one or the other to be the 'winner' and the only tool that handles running yarn install.

From what I can tell, the nodejs buildpack sees that we have a a package.json with a build task, so it installs node and yarn and then executes yarn run.

Then the ruby buildpack detects the ruby app, and runs the assets precompile task, which again runs the same steps (which I believe jsbundling-rails wires up).

I suppose we could try to explicitly clear out the precompile task in Rails land, but that feels pretty hacky and not a good long-term solution.

Is there an ENV var or flag we could set to tell the nodejs task to not try to build things, and instead let the ruby build pack be the 'builder' ?

Here are our buildpacks btw:

1. https://github.com/lstoll/heroku-buildpack-monorepo
2. https://github.com/DataDog/heroku-buildpack-datadog.git
3. https://github.com/heroku/heroku-buildpack-nginx
4. heroku/nodejs
5. heroku/ruby

And here is the output of a recent heroku deploy showing the multiple calls to yarn install.

@dhh
Copy link
Member

dhh commented Jan 3, 2023

I'd take a SKIP_YARN_INSTALL additional ENV for the build task, if you'd like to work on that.

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.

2 participants