google / zx

A tool for writing better scripts

Home Page:https://google.github.io/zx/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Script fails if it is hardlinked

NobbZ opened this issue · comments

Expected Behavior

My script runs

Actual Behavior

An error message is printed complaining about the script being hardlinked more than once:

/nix/store/qggprwbjq1hq7f7rd8jrl9jw4sj0wg3z-xz-5.2.5-bin/bin/xz: /nix/store/s2n4ck3flkd6k8r9a85bhlna137rbm9c-nobbz-flake-updater-0.0.2/lib/update.mjs: Input file has more than one hard link, skipping

Steps to Reproduce the Problem

  1. create a foo.mjs
  2. zx foo.mjs and everything works well
  3. cp -l foo.mjs bar.mjs
  4. zx foo.mjs or zx bar.mjs and it fails

Specifications

  • Version: 5.2.0
  • Platform: Linux

Additional Context:

Hardlinking individual files is a common technique in NixOS (and with nix in general) to reduce storage usage, as by the nature of nix a lot of identical files are produced in the "store" where "packages" live, each with its own "prefix". This "store" is mounted RO and therefore the hardlinking is considered save.

This becomes a problem when one wants to create a Nix package from zx-scripts.

Hey @NobbZ,

Have you tried running it with NODE_PRESERVE_SYMLINKS env?

No response. Let's close.

Yeah, sorry, I was unable to recreate the issue when I tried again a day later. Also I moved the three zx scripts I had into a single precompiled rust binary, as it isn't requiring as much of runtime stuff to be installed.

I do concur with closing this. Thank you for your help anyway!