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

pnpm.fetchDeps: error if lockfile version has a mismatch #317739

Merged
merged 2 commits into from
Jun 28, 2024

Conversation

SuperSandro2000
Copy link
Member

@SuperSandro2000 SuperSandro2000 commented Jun 6, 2024

Description of changes

Tested while updating youtube-music

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@SuperSandro2000 SuperSandro2000 changed the title pnpm.fetchDeps: error if lockfile version has a mismatch pnpm.fetchDeps: error if lockfile version has a mismatch, remove packageManager key from package.json Jun 6, 2024
Comment on lines 55 to 59
# Don't force us to use an older version of pnpm. A newer version probably generates another FOD though.
jq --sort-keys "del(.. | .packageManager?)" package.json | sponge package.json

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a similar vein as Python relaxDepsHook, this should probably be a flag that's off by default.

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jun 6, 2024
doc/languages-frameworks/javascript.section.md Outdated Show resolved Hide resolved
doc/languages-frameworks/javascript.section.md Outdated Show resolved Hide resolved
pkgs/development/tools/pnpm/fetch-deps/default.nix Outdated Show resolved Hide resolved
pkgs/development/tools/pnpm/fetch-deps/default.nix Outdated Show resolved Hide resolved
doc/languages-frameworks/javascript.section.md Outdated Show resolved Hide resolved
@SuperSandro2000 SuperSandro2000 changed the title pnpm.fetchDeps: error if lockfile version has a mismatch, remove packageManager key from package.json pnpm.fetchDeps: error if lockfile version has a mismatch Jun 18, 2024
@SuperSandro2000
Copy link
Member Author

I've removed remove packageManager key from package.json for now because it didn't work like I envisioned it with the further testing I just did.

Copy link
Contributor

@doronbehar doronbehar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit besides the comment below: The first commit message should start with pnpm.fetchDeps,

];

installPhase = ''
runHook preInstall

lockfileVersion="$(yq -r .lockfileVersion pnpm-lock.yaml)"
if [[ ''${lockfileVersion:0:1} -gt ${lib.versions.major pnpm.version} ]]; then
echo "ERROR: lockfileVersion in pnpm-lock.yaml is to new for the provided pnpm version ${lib.versions.major pnpm.version}!"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started with some corrections and improvements, and continued with a suggested way to overcome this check.

Suggested change
echo "ERROR: lockfileVersion in pnpm-lock.yaml is to new for the provided pnpm version ${lib.versions.major pnpm.version}!"
echo "ERROR: lockfileVersion $lockfileVersion in pnpm-lock.yaml is" \
"too new for the provided pnpm version" \
"${lib.versions.major pnpm.version}! Set" \
"pnpmDontCheckLockfileVersion=true to avoid this error if you're" \
"sure it won't cause other issues" >&2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That won't do anything, as pnpm will fail with a rather cryptic error message anyway.

@gepbird
Copy link
Contributor

gepbird commented Jun 18, 2024

I've removed remove packageManager key from package.json for now because it didn't work like I envisioned it with the further testing I just did.

Can you share more details about the issue that made you remove it?

@SuperSandro2000
Copy link
Member Author

Can you share more details about the issue that made you remove it?

It needed to be in mkDerivation and inside fetchDeps and got more complicated the more deeply I tested it.

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Jun 26, 2024
@SuperSandro2000 SuperSandro2000 merged commit 31efaed into NixOS:master Jun 28, 2024
20 checks passed
@SuperSandro2000 SuperSandro2000 deleted the pnpm-fetch-deps branch June 28, 2024 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nodejs 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux 12.approvals: 1 This PR was reviewed and approved by one reputable person
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants