Conversation
aduh95
commented
Jan 28, 2024
arcanis
approved these changes
Jan 30, 2024
| } | ||
|
|
||
| if (process.env.COREPACK_DEFAULT_TO_LATEST !== `0`) { | ||
| let lastKnownGoodFile: FileHandle; |
Contributor
There was a problem hiding this comment.
nit: Not a fan of working with file handles; it makes the code harder to follow for something that's relatively trivial perf-wise.
Contributor
Author
There was a problem hiding this comment.
We were reading and parsing the same JSON twice, so at least that should improve the perf ever so slightly. But I think it's the only way to avoid race conditions in case other processes are touching the same file.
maxrake
added a commit
to phylum-dev/phylum-ci
that referenced
this pull request
Feb 22, 2024
The lockfile generation tool `yarn` fails when used in the `phylum-ci` Docker image as a non-root user. An example of the failure can be seen from the output of the "smoke test," which is using `scripts/docker_tests.sh` to ensure basic functionality: ``` yarn --version Internal Error: EACCES: permission denied, open '/usr/local/corepack/lastKnownGood.json' Error: EACCES: permission denied, open '/usr/local/corepack/lastKnownGood.json' ``` The same behavior happens for `pnpm`. These are the tools installed by `corepack`, which changed recently to "Bump Known Good Release when downloading new version" (nodejs/corepack#364). Part of that change was to make use of the `COREPACK_DEFAULT_TO_LATEST` environment variable to *not* update the last known good version, but setting that to `0` does not appear to prevent *all* writes (or creating a file handle with write permission) to the `lastKnownGood.json` file. This fix simply modifies the file permissions for `lastKnownGood.json` so that non-root users can read and write to it. This approach may seem specific to a file that may change name or location in the future, but the alternative method of adding `${COREPACK_HOME}` to the list of directories that get updated with a `chmod -vR 777` was deemed to be too blunt and therefore less desirable.
maxrake
added a commit
to phylum-dev/phylum-ci
that referenced
this pull request
Feb 22, 2024
The lockfile generation tool `yarn` fails when used in the `phylum-ci` Docker image as a non-root user. An example of the failure can be seen from the output of the "smoke test," which is using `scripts/docker_tests.sh` to ensure basic functionality: ``` yarn --version Internal Error: EACCES: permission denied, open '/usr/local/corepack/lastKnownGood.json' Error: EACCES: permission denied, open '/usr/local/corepack/lastKnownGood.json' ``` The same behavior happens for `pnpm`. These are the tools installed by `corepack`, which changed recently to "Bump Known Good Release when downloading new version" (nodejs/corepack#364). Part of that change was to make use of the `COREPACK_DEFAULT_TO_LATEST` environment variable to *not* update the last known good version, but setting that to `0` does not appear to prevent *all* writes (or creating a file handle with write permission) to the `lastKnownGood.json` file. This fix simply modifies the file permissions for `lastKnownGood.json` so that non-root users can read and write to it. This approach may seem specific to a file that may change name or location in the future, but the alternative method of adding `${COREPACK_HOME}` to the list of directories that get updated with a `chmod -vR 777` was deemed to be too blunt and therefore less desirable. --------- Co-authored-by: Kyle Willmon <kyle@phylum.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When Corepack downloads a new version, it checks if it corresponds to same major as the global cached one, and if it does, it uses the more recent one the next time the global version is used. That should give users a more smoother experience as they won't need to call
corepack install -gas often – with this PR, it should be needed only when wanting to use a different major, assuming you work on projects that keep their"packageManager"field up-to-date.