`fs.fchown` is not a function
Extracting using tar fails with fs.fchown is not a function error.
Reproducible steps:
// tar_compat.ts
import * as tar from "npm:[email protected]";
import { pipeline } from "node:stream/promises";
await fetch(
"https://github.com/informalsystems/apalache/releases/download/v0.44.11/apalache.tgz",
).then((resp) =>
pipeline(
resp.body,
tar.extract({ cwd: ".", strict: true }),
)
);
~ # deno run -A tar_compat.ts
error: Uncaught (in promise) TypeError: fs.fchown is not a function
at WriteStream.<anonymous> (file:///deno-dir/npm/registry.npmjs.org/tar/7.4.0/dist/esm/unpack.js:468:24)
at WriteStream.emit (ext:deno_node/_events.mjs:386:28)
at WriteStream.emit (file:///deno-dir/npm/registry.npmjs.org/@isaacs/fs-minipass/4.0.1/dist/esm/index.js:252:22)
at WriteStream.[_onwrite] (file:///deno-dir/npm/registry.npmjs.org/@isaacs/fs-minipass/4.0.1/dist/esm/index.js:337:26)
at file:///deno-dir/npm/registry.npmjs.org/@isaacs/fs-minipass/4.0.1/dist/esm/index.js:319:87
at ext:deno_node/_fs/_fs_write.mjs:105:9
at eventLoopTick (ext:core/01_core.js:168:7)
The apalache.tgz's content permissions:
~ # curl -sLO https://github.com/informalsystems/apalache/releases/download/v0.44.11/apalache.tgz
~ # tar -tvf apalache.tgz
drwxr-xr-x runner/docker 0 2024-05-06 12:37 apalache/
-rw-r--r-- runner/docker 11945 2024-05-06 12:37 apalache/LICENSE
drwxr-xr-x runner/docker 0 2024-05-06 12:37 apalache/lib/
-rw-r--r-- runner/docker 104008305 2024-05-06 12:37 apalache/lib/apalache.jar
drwxr-xr-x runner/docker 0 2024-05-06 12:37 apalache/bin/
-rwxr-xr-x runner/docker 1945 2024-05-06 12:37 apalache/bin/apalache-mc
Version: Deno 1.44.4
@rnbguy may I know the platform you're encoutering the issue on? The script works fine with Deno 1.44.4 on macOS
➜ 24314 deno --version
deno 1.44.4 (release, aarch64-apple-darwin)
v8 12.6.228.9
typescript 5.4.5
➜ 24314 cat a.ts
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: a.ts
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ import * as tar from "npm:[email protected]";
2 │ import { pipeline } from "node:stream/promises";
3 │
4 │ await fetch(
5 │ "https://github.com/informalsystems/apalache/releases/download/v0.44.11/apalache.tgz",
6 │ ).then((resp) =>
7 │ pipeline(
8 │ resp.body,
9 │ tar.extract({ cwd: ".", strict: true }),
10 │ )
11 │ );
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
➜ 24314 deno run -A a.ts
➜ 24314 ls -lR apalache
total 24
-rw-r--r-- 1 sr staff 11945 May 6 18:07 LICENSE
drwxr-xr-x 3 sr staff 96 Jun 24 12:10 bin
drwxr-xr-x 3 sr staff 96 Jun 24 12:10 lib
apalache/bin:
total 8
-rwxr-xr-x 1 sr staff 1945 May 6 18:07 apalache-mc
apalache/lib:
total 230920
-rw-r--r-- 1 sr staff 104008305 May 6 18:07 apalache.jar
I am on Linux.
I just realized, this works fine on my personal Arch Linux computer. But fails on docker images. I tried:
alpine,debian,ubuntutags fordenoland/denoimage.archlinuximage withpacman -S deno(same setup as my personal computer).
It looks like it might be something with root user. The following works fine:
$ docker run --user=deno --workdir=/home/deno denoland/deno:alpine eval '
import * as tar from "npm:[email protected]";
import { pipeline } from "node:stream/promises";
await fetch(
"https://github.com/informalsystems/apalache/releases/download/v0.44.11/apalache.tgz",
).then((resp) =>
pipeline(
resp.body,
tar.extract({ cwd: ".", strict: true }),
)
);
'
If you remove --user=deno or --workdir=/home/deno, the command fails.
Ref https://github.com/denoland/deno/issues/18218
Same here when installing the NPM Package cpu-features with deno version 2.0.3.
My Full Stacktrace:
Initialize [email protected]: running 'install' script
error: script 'install' in '[email protected]' failed with exit code 7
stderr:
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info find Python using Python version 3.11.2 found at "/usr/bin/python3"
gyp http GET https://nodejs.org/download/release/v20.11.1/node-v20.11.1-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v20.11.1/node-v20.11.1-headers.tar.gz
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack TypeError: fs.fchown is not a function
gyp ERR! stack at WriteStream.<anonymous> (file:///home/container/node_modules/.deno/[email protected]/node_modules/tar/lib/unpack.js:482:12)
gyp ERR! stack at WriteStream.emit (ext:deno_node/_events.mjs:393:28
gyp ERR! stack at WriteStream.emit (file:///home/container/node_modules/.deno/[email protected]/node_modules/fs-minipass/index.js:257:18)
gyp ERR! stack at WriteStream.[_onwrite] (file:///home/container/node_modules/.deno/[email protected]/node_modules/fs-minipass/index.js:342:16)
gyp ERR! stack at file:///home/container/node_modules/.deno/[email protected]/node_modules/fs-minipass/index.js:325:21
gyp ERR! stack at ext:deno_node/_fs/_fs_write.mjs:102:9
gyp ERR! stack at eventLoopTick (ext:core/01_core.js:175:7)
gyp ERR! System Linux ***** (Censored by me)
gyp ERR! command "node-gyp" "/home/container/node_modules/.deno/[email protected]/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/container/node_modules/.deno/[email protected]/node_modules/cpu-features
gyp ERR! node -v v20.11.1
gyp ERR! node-gyp -v v10.2.0
gyp ERR! Node-gyp failed to build your package.
gyp ERR! Try to update npm and/or node-gyp and if it does not help file an issue with the package author.
error: failed to run scripts for packages: [email protected]
Anybody found a workaround/solution to this?
It should be fixed now. This works on the latest:
$ docker run --pull=always denoland/deno:alpine eval '
import * as tar from "npm:[email protected]";
import { pipeline } from "node:stream/promises";
await fetch(
"https://github.com/informalsystems/apalache/releases/download/v0.44.11/apalache.tgz",
).then((resp) =>
pipeline(
resp.body,
tar.extract({ cwd: "/root", strict: true }),
)
);
'
@bartlomieju feel free to close this issue as my original issue is resolved.