-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Move yarn and npm5 cache directories #439
Comments
For anyone running into the CI issue before I can get this change in, you can fix your CI tests by adding the following config to your
|
I ran into a similar issue today when setting up Heroku CI with jest: jest-haste-map: @providesModule naming collision:
Duplicate module name: protobufjs
Paths: /app/.cache/yarn/v1/npm-protobufjs-5.0.2-59748d7dcf03d2db22c13da9feb024e16ab80c91/package.json collides with /app/.cache/yarn/v1/npm-protobufjs-6.8.0-04e85493c4e1653878ec283f18bc78b1e7c5d5a2/package.json
This warning is caused by a @providesModule declaration with the same name across two different files. This warning was repeated a few hundred times, once for each duplicate package! Adding I suppose I was slightly confused that the Yarn cache directory wasn't a tmp dir as this issue suggests! Has this fix been released, or perhaps I need to explicitly specify the latest buildpack version (currently not specified in |
@benhjames The cache directory should be in a temp directory by default now with the main buildpack release. You might be pinned to an old version maybe? You might be hitting #494 though I'm still confused how If you open a support ticket at help.heroku.com I can dig in and figure out what's going on :) |
Thanks @jmorrell, I've opened a support ticket. :) AFAIK I've not specified the buildpack version anywhere, so I'm guessing it should be pulling the latest release. |
Re-opening this after looking into @benhjames issues some more |
@jmorrell As I understand packager cache dirs created in /tmp folder now, by this code: heroku-buildpack-nodejs/bin/compile Lines 24 to 25 in 6c52af1
If they were cached, this would have increased build speed. Why these dirs are not cached? |
@Vlasenko The short answer is that I haven't yet had the time to investigate and measure the trade-offs vs caching In the mean time, if you want to configure your app to cache these, you can set If you do this I believe you will eventually need to clean up the cache directory since over time it will hold copies of modules that you no longer use in your deployment (old minor versions, etc), which will bloat your slug. npm provides |
@jmorrell Thank you for sharing your concerns. I have created A couple more points:
|
@jmorrell Another point to consider about caching is that starting build in unique folder each time, i.e. |
Closing since this issue is fixed, but I will be looking into the points raised by @Vlasenko |
@jmorrell Out of curiosity, did this conversation around |
@loganfsmyth I'm afraid I got distracted by a different project and completely forgot about that. At some point I'd like to improve our caching story around frontend builds. We cache |
@jmorrell Totally fair. The main point that I've heard is the general concern about the build dir being unique per-build, because then any caches built using absolute paths automatically invalidate between builds, so that's the main thing I was curious about. It seems like having a stable build directory path would go a long way toward allow stable caching. |
@loganfsmyth I agree. Unfortunately that has been in our backlog forever, and my efforts at getting it prioritized haven't been successful. |
Cool, no worries, I know how that goes. At least now I can decide if it's worth tackling on our side. Thanks for getting back to me! |
Yarn and npm5 both have cache directories that get defaulted to the
$HOME
directory on linux.~/.npm
for npm5 and~/.cache/yarn
for yarn.This creates an issue for Heroku since
$HOME=/app
which is the same directory where your application is run. So far this hasn't been a problem because apps are built in a temporary directory, but this will be changing to/app
as well in the future. If this were to happen today we'd see a big increase in slug size because the cache directory would be included along with your application.It's a bigger issue in Heroku CI in the case of running tests with Jest. Jest will automatically pick up tests in the cache directory, causing your CI tests to fail in hard-to-debug ways when they run fine locally. Context: jestjs/jest#3935
The solution in both cases is to take control of the cache directories and move them into
/tmp
by default. Though if users want to cache these cache directories we need to provide a mechanism for them to be able to.The text was updated successfully, but these errors were encountered: