Skip to content

fetchPnpmDeps: don't fail on empty lockfile#513736

Merged
Scrumplex merged 1 commit into
NixOS:masterfrom
sepointon:push-qptmstlyyyvn
Apr 26, 2026
Merged

fetchPnpmDeps: don't fail on empty lockfile#513736
Scrumplex merged 1 commit into
NixOS:masterfrom
sepointon:push-qptmstlyyyvn

Conversation

@sepointon

Copy link
Copy Markdown
Contributor

If the lockfile is empty, no files will be put in the output directory. In this case, the find invocations produce an empty list of results. xargs' default behaviour is to always invoke its command at least once; if its input is empty, then its command will not be passed any filenames. This produces an invocation like chmod 555, with no further operands. chmod, however, fails in this case, expecting an operand. So we need to tell xargs not to invoke its command at all in the case of empty input.

I went looking for some examples of fetchPnpmDeps tests to pattern off, since this is an almost ideal bug to have a regression test for (literally no network access needed!), but I couldn't find any; figuring out a good way to set up tests for it is more effort than I want to spend on this, so no test is being added. If there are some and I just missed them, I'm happy to amend the PR and add to their number. In their absence, I offer an assurance that I have manually tested it and found the patch fixed the failure I saw (albeit rebased on a commit from a few days ago instead of the present master).

Because this is only fixing a case that was failing builds before, this shouldn't change any previously-working output and hence isn't a fetcher version change. (I think, anyway!)

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

@sepointon

Copy link
Copy Markdown
Contributor Author

Also, I should note that this does not bite people with fetcherVersion = 1, only 2 or 3, hence it has an unfortunate interaction with #513215: without fixing this, people will be being nagged about a deprecation, but may not have a simple way to bump the fetcher version and squelch it.

@nixpkgs-ci nixpkgs-ci Bot requested review from Scrumplex and gepbird April 26, 2026 16:47
@nixpkgs-ci nixpkgs-ci 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. 6.topic: nodejs Node.js is a free, open-source, cross-platform JavaScript runtime environment labels Apr 26, 2026
@Scrumplex

Copy link
Copy Markdown
Member

I was working on adding tests in this PR: #505103

@Scrumplex Scrumplex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changes LGTM. Due to this fixing a build failure, I think we can safely assume that this won't break any existing hashes.

I'd say this is good to merge even without a test at the moment, but if you want to add one based on my previous comment, I am happy to re-review then :D

@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Apr 26, 2026
@sepointon

Copy link
Copy Markdown
Contributor Author

Ta - that was enough to pattern off, and now there is a test: validated that it fails with the previous code, and that it's fixed by the PR.

@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. and removed 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 Apr 26, 2026
If the lockfile is empty, no files will be put in the output directory. 
In this case, the find invocations produce an empty list of results. 
xargs' default behaviour is to always invoke its command at least once; 
if its input is empty, then its command will not be passed any 
filenames. This produces an invocation like `chmod 555`. chmod, however, 
fails in this case, expecting an operand. So we need to tell xargs not 
to invoke its command at all in the case of empty input.
@Scrumplex

Copy link
Copy Markdown
Member

Thank you!

@Scrumplex Scrumplex added this pull request to the merge queue Apr 26, 2026
@Scrumplex Scrumplex added the backport release-25.11 Backport PR automatically label Apr 26, 2026
Merged via the queue into NixOS:master with commit 8aea0bd Apr 26, 2026
28 checks passed
@nixpkgs-ci

nixpkgs-ci Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Backport failed for release-25.11, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-25.11
git worktree add -d .worktree/backport-513736-to-release-25.11 origin/release-25.11
cd .worktree/backport-513736-to-release-25.11
git switch --create backport-513736-to-release-25.11
git cherry-pick -x 37955437a78e6effe93022d70a131ff88e92a08e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nodejs Node.js is a free, open-source, cross-platform JavaScript runtime environment 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person. backport release-25.11 Backport PR automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants