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

fs.fchown is not a function #24314

Open
rnbguy opened this issue Jun 22, 2024 · 4 comments
Open

fs.fchown is not a function #24314

rnbguy opened this issue Jun 22, 2024 · 4 comments
Labels
bug Something isn't working correctly node compat

Comments

@rnbguy
Copy link

rnbguy commented Jun 22, 2024

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

@marvinhagemeister marvinhagemeister added bug Something isn't working correctly node compat labels Jun 22, 2024
@satyarohith
Copy link
Member

@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

@rnbguy
Copy link
Author

rnbguy commented Jun 24, 2024

I am on Linux.

@rnbguy
Copy link
Author

rnbguy commented Jun 24, 2024

I just realized, this works fine on my personal Arch Linux computer. But fails on docker images. I tried:

  1. alpine, debian, ubuntu tags for denoland/deno image.
  2. archlinux image with pacman -S deno (same setup as my personal computer).

@rnbguy
Copy link
Author

rnbguy commented Jun 25, 2024

It looks like it might be something with root user. The following Dockerfile works fine:

FROM archlinux

RUN pacman -Sy --noconfirm deno

RUN useradd -ms /bin/bash newuser
USER newuser
WORKDIR /home/newuser

COPY --chown=newuser:newuser tar_compat.ts /home/newuser/tar_compat.ts
(host) $ docker build -t deno-arch .
(host) $ docker run -it --rm deno-arch
(docker) $ deno run -A tar_compat.ts # success

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat
Projects
None yet
Development

No branches or pull requests

3 participants