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

[BUG] FetcherBase._tarxOptions removes files with identical inodes #285

Open
1 task done
rekado opened this issue Jul 4, 2023 · 1 comment
Open
1 task done
Labels
Bug thing that needs fixing Needs Triage needs an initial review

Comments

@rekado
Copy link

rekado commented Jul 4, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

_tarxOptions in FetcherBase specifies an extraction filter that removes any tar entry that has a type matching Link. node-tar marks files that have more than one hardlink on them as being of type Link. This makes the behavior of tarballStream differ dependent on whether one of the source files happens to have the same inode as another source file. Only one copy of the hardlinked files will thus end up in the target directory.

This is problematic for systems like Guix System where identical files may be deduplicated with hardlinks.

Expected Behavior

The effective output of the tarballStream should be the same independent of whether the involved files share inodes.

Steps To Reproduce

mkdir pkgA
cat<<EOF>>pkgA/package.json
{
  "name": "pkgA",
  "version": "0.0.0",
  "description": "",
  "dependencies": {
    "pkgB": "../pkgB"
  },
  "author": "",
  "license": ""
}
EOF
mkdir pkgB
cat<<EOF>>pkgB/package.json
{
  "name": "pkgB",
  "version": "0.0.0",
  "description": "",
  "author": "",
  "license": ""
}
EOF
touch pkgB/index.js
mkdir pkgB/dist

# duplicate a file via hardlink
ln pkgB/index.js pkgB/dist/index.js 

This is what this looks like:

$ tree
.
├── pkgA
│   └── package.json
└── pkgB
    ├── dist
    │   └── index.js
    ├── index.js
    └── package.json

4 directories, 4 files

Now install pkgA and observe that index.js only appears once.

cd pkgA
npm install --offline --install-links=true

We only see dist/index.js, not its hardlinked alter ego:

$ tree node_modules
node_modules/
└── pkgB
    ├── dist
    │   └── index.js
    └── package.json

Environment

  • npm: 9.5.1
  • Node: v18.16.0
  • OS: Guix System
  • platform: x86_64
@rekado rekado added Bug thing that needs fixing Needs Triage needs an initial review labels Jul 4, 2023
@rekado
Copy link
Author

rekado commented Jul 12, 2023

If you think that this is rather a bug report for node-tar, please do say so. Perhaps it should not label hardlinked files as Link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs an initial review
Projects
None yet
Development

No branches or pull requests

1 participant