Skip to content

Commit b7beb69

Browse files
committed
fix(bundle): tar --hard-dereference in bundle archive (npm E415)
npm's per-tarball publish endpoint returns HTTP 415 'Unsupported Media Type - Hard link is not allowed' when the tarball contains hard links. \pnpm install --prod --config.node-linker=hoisted\ (added in commit bb58f8d to fix issue #28) leaves hard links inside \ ode_modules/\ — those are fine on disk but \ ar -czf\ preserves them as hard links in the archive, which npm rejects. \ ar --hard-dereference\ dereferences every hard link to a copy of the underlying inode before writing the archive, producing a flat tree of regular files. Cost: a few MB of disk on the bundle (most hard links in node_modules are small files), negligible against the time saved by not re-architecting pnpm's hardlink strategy. Verified locally: \ ar --no-xattrs --hard-dereference -czf /tmp/test.tar.gz -C /tmp/extract codegraph-vba-linux-x64\ produces a tarball with 0 hard links, vs. the previous 1,847.
1 parent 2f3e969 commit b7beb69

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎scripts/build-bundle.sh‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ if [ "$OSFAM" = "win32" ]; then
135135
else
136136
ARCHIVE="$OUT/codegraph-vba-${TARGET}.tar.gz"
137137
# --no-xattrs: don't embed macOS xattrs that make GNU tar warn on Linux.
138-
tar --no-xattrs -czf "$ARCHIVE" -C "$WORK" "codegraph-vba-${TARGET}"
138+
# --hard-dereference: replace hard links in node_modules (left over from
139+
# `pnpm install --prod --config.node-linker=hoisted`) with copies of the
140+
# target. npm's per-tarball publish endpoint rejects PUTs whose tarball
141+
# contains hard links (HTTP 415 - Hard link is not allowed), so the bundle
142+
# archive must be a flat tree of regular files.
143+
tar --no-xattrs --hard-dereference -czf "$ARCHIVE" -C "$WORK" "codegraph-vba-${TARGET}"
139144
fi
140145
echo "[bundle] wrote ${ARCHIVE} ($(du -h "$ARCHIVE" | cut -f1))"

0 commit comments

Comments
 (0)