rome / tools

Unified developer tools for JavaScript, TypeScript, and the web
https://docs.rome.tools/
MIT License
23.74k stars 659 forks source link

🐛 ENOENT error on `node:18-alpine` container #4632

Open ZendyLim opened 1 year ago

ZendyLim commented 1 year ago

Environment information

/home/node/project-tsuki/server/node_modules/rome/bin/rome:37
                throw result.error;
                ^

Error: spawnSync /home/node/project-tsuki/server/node_modules/@rometools/cli-linux-x64/rome ENOENT
    at Object.spawnSync (node:internal/child_process:1110:20)
    at Object.spawnSync (node:child_process:871:24)
    at Object.<anonymous> (/home/node/project-tsuki/server/node_modules/rome/bin/rome:21:42)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawnSync /home/node/project-tsuki/server/node_modules/@rometools/cli-linux-x64/rome',
  path: '/home/node/project-tsuki/server/node_modules/@rometools/cli-linux-x64/rome',
  spawnargs: [ 'rage' ]
}

Node.js v18.16.1

What happened?

I have this docker and docker-compose configuration for VSCode devcontainer

FROM node:18-alpine

# Install git, openssh and zsh 
RUN apk add --no-cache curl git openssh zsh

# Set user to non-root
USER node

# Install Oh My ZSH and set ZSH as default shell
RUN sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
ENV SHELL=/bin/zsh

# Set working directory
WORKDIR /home/node/project-tsuki/server
services:
  base:
    container_name: project-tsuki-server
    build:
      context: .
      dockerfile: ./Dockerfile
    volumes:
      - ..:/home/node/project-tsuki/server
    command: /bin/sh -c "while sleep 1000; do :; done"   
  1. Run npm i -D rome
  2. Run npx rome init

It exits with error below

/home/node/project-tsuki/server/node_modules/rome/bin/rome:37
                throw result.error;
                ^

Error: spawnSync /home/node/project-tsuki/server/node_modules/@rometools/cli-linux-x64/rome ENOENT
    at Object.spawnSync (node:internal/child_process:1110:20)
    at Object.spawnSync (node:child_process:871:24)
    at Object.<anonymous> (/home/node/project-tsuki/server/node_modules/rome/bin/rome:21:42)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawnSync /home/node/project-tsuki/server/node_modules/@rometools/cli-linux-x64/rome',
  path: '/home/node/project-tsuki/server/node_modules/@rometools/cli-linux-x64/rome',
  spawnargs: [ 'rage' ]
}

Expected result

Should be success and create a configuration file.

Code of Conduct

ematipico commented 1 year ago

Make sure that your container installs @rometools/cli-linux-x64 and it's inside node_modules. If not, it means that your package manager didn't install optionalDependencies. You will need to install it manually yourself.

ZendyLim commented 1 year ago

I've looked into the node_modules and @rometools/cli-linux-x64/rome exists.

ls -lAh /home/node/project-tsuki/server/node_modules/@rometools/cli-linux-x64/rome
-rwxr-xr-x    1 node     node       13.5M Jun 29 15:27 /home/node/project-tsuki/server/node_modules/@rometools/cli-linux-x64/rome
ematipico commented 1 year ago

To be honest, I'm not sure what the issue is. Probably some symbol link or something?

I never installed Rome this way.

ZendyLim commented 1 year ago

So in attempt to work around this. I figured that alpine might missing some glibc stuff. So I installed it.

wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub \
 && wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r1/glibc-2.35-r1.apk \
 && wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r1/glibc-bin-2.35-r1.apk \
 && apk add glibc-2.35-r1.apk glibc-bin-2.35-r1.apk \
 && rm glibc-2.35-r1.apk glibc-bin-2.35-r1.apk

Now doesn't throw ENOENT error anymore.

npx rome init
Error relocating /home/node/project-tsuki/server/node_modules/@rometools/cli-linux-x64/rome: __register_atfork: symbol not found
Error relocating /home/node/project-tsuki/server/node_modules/@rometools/cli-linux-x64/rome: gnu_get_libc_version: symbol not found

Tried with Ubuntu and Debian version of node Docker Image and it works fine.

will-path commented 1 year ago

Also running into this on a node:18-alpine container. @rometools/cli-linux-arm64 is linked against /lib/ld-linux-aarch64.so.1 which isn't part of Alpine. I tried installing gcompat and then got this:

Rome encountered an unexpected error

This is a bug in Rome, not an error in your code, and we would appreciate it if you could report it to https://github.com/rome/tools/issues/ along with the following information to help us fixing the issue:

Source Location: library/alloc/src/raw_vec.rs:525:5
Thread Name: main
Message: capacity overflow

Also tried libc6-compat and it comes up with a different error:

Error relocating /opt/redacted/.yarn/unplugged/@rometools-cli-linux-arm64-npm-12.1.3-1a684f2047/node_modules/@rometools/cli-linux-arm64/rome: __register_atfork: symbol not found
Error relocating /opt/redacted/.yarn/unplugged/@rometools-cli-linux-arm64-npm-12.1.3-1a684f2047/node_modules/@rometools/cli-linux-arm64/rome: gnu_get_libc_version: symbol not found

Is it possible to build Rome for musl? For now I'll just run Rome outside of the container against my source code.

SparksFlyx3 commented 1 year ago

I ran into the same problem with lts-alpine3.18.. We are trying to migrate our existing project from ESLint to rome. Is there a solution yet?