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

Binary caching does not respect cache setting #856

Closed
lizzielizzielizzie opened this issue Nov 13, 2020 · 4 comments
Closed

Binary caching does not respect cache setting #856

lizzielizzielizzie opened this issue Nov 13, 2020 · 4 comments

Comments

@lizzielizzielizzie
Copy link

Hi,
I'm currently working on tuning our CI performance but I've run into an issue where sentry's install script is always downloading the binary to ~/.npm/ rather than the directory configured in my .npmrc or the directory specified when running npm ci --cache myProjectCacheFolder. Because it's not installing to the correct cache folder, our runners can't pick it up, which means it gets redownloaded for each job (🙁)

I don't have this issue with any other package, as~/.npm/ only has the sentry-cli folder (everything else is in my project's cache folder). I also added a little script to my package.json

  scripts: {
    "print-env-vars": "printenv | grep npm_config_cache"
  }

and running the command outputs

npm_config_cache=myProjectCacheFolder

Which means the setting is definitely correct at the "top leve", but perhaps not carried through into the install script's environment. If you have any ideas at all for how to resolve this, I'd be really appreciative, as I've been scratching my head on this one all day

@kamilogorek
Copy link
Contributor

What CI are you using? Different services handle caches differently. I just verified it locally, and both scenarios (config option and --cache) work just fine - fetch first, use cached on 2nd run.

image

image

@lizzielizzielizzie
Copy link
Author

We're using gitlab, but I'm able to reproduce the issue just on my mac with npm v6.10.3 and node v12.10.0
Screen Shot 2020-11-16 at 9 28 32 AM

At the end of this screenshot you can see that even though the npm cache has been placed inside the project directory (consistent with the env setting), sentry-cli's cache for the binary has been placed at ~/.npm/sentry-cli

If we run npm ci again, it uses the cache and never fetches the binary. This is good, ‼but‼ if we delete ~/.npm, which is not where the cache has been configured, it has to fetch the binary again to install, again indicating the binary is saved where it shouldn't be.
image

I would assume this behavior is because of this line in the setup script, but I don't understand why process.env.npm_config_cache is unset at that point.

@lizzielizzielizzie
Copy link
Author

Turns out it was an issue with npm ci dropping certain config settings from the environment. Upgrading npm to the latest version solved the issue :) You can read more here

@kamilogorek
Copy link
Contributor

Good to know, thanks!

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

2 participants