Skip to content

Instantly share code, notes, and snippets.

@infomiho
Last active February 15, 2026 18:17
Show Gist options
  • Select an option

  • Save infomiho/e96b9742075865036b461c084f7e64e3 to your computer and use it in GitHub Desktop.

Select an option

Save infomiho/e96b9742075865036b461c084f7e64e3 to your computer and use it in GitHub Desktop.
wasp-cli 0.17.2 npm: 'chdir: invalid argument (Bad file descriptor)' — missing data/packages/ in published npm package

wasp db migrate-dev fails with chdir: invalid argument (Bad file descriptor)

Bug

Running wasp db migrate-dev (installed via npm install -g @wasp.sh/wasp-cli@0.17) fails with:

Setting up database...
wasp-bin: npm: readCreateProcessWithExitCode: chdir: invalid argument (Bad file descriptor)

Originally reported as a WSL2-specific issue, but it reproduces on any Linux environment using the npm-installed Wasp CLI v0.17.2.

Root Cause

The published npm package @wasp.sh/wasp-cli-linux-x64-glibc@0.17.2 is missing the data/packages/ directory. This directory contains built TypeScript sub-packages (prisma, deploy, ts-inspect, studio, wasp-config) that the Haskell binary needs at runtime.

The error occurs during the "Setting up database..." phase:

  1. Wasp.Psl.Format.prismaFormat calls NodePackageFFI.getPackageProcessOptions PrismaPackage
  2. This calls ensurePackageDependenciesAreInstalled, which runs npm install with cwd set to $waspc_datadir/packages/prisma/
  3. That directory does not exist in the npm package — data/ only contains Cli/, Generator/, and Lsp/
  4. Haskell's readCreateProcessWithExitCode tries to chdir into the non-existent directory → EBADF

You can verify the directory is missing:

npm pack @wasp.sh/wasp-cli-linux-x64-glibc@0.17.2
tar -tzf wasp.sh-wasp-cli-linux-x64-glibc-0.17.2.tgz | grep packages/
# (no output — zero files under packages/)

The files are declared in waspc.cabal (data-files lines 61–79, e.g. packages/prisma/dist/**/*.js) and are supposed to be included by tools/make_binary_package.sh via cabal sdist --list-only. They were either not built or not captured when the 0.17.2 npm tarball was assembled.

Reproduce

docker build --platform linux/amd64 -f Dockerfile.repro -t wasp-repro .

docker run --rm wasp-repro bash -c '
  wasp new testapp 2>&1 && \
  cd testapp && \
  wasp db migrate-dev 2>&1
'

The compilation phase (npm install for the project) succeeds. The error appears at "Setting up database...".

Workaround

Install Wasp via the shell installer instead of npm:

curl -sSL https://get.wasp.sh/installer.sh | sh -s -- -v 0.17.2

The shell installer distributes tarballs from GitHub Releases, which include the complete data/packages/ directory.

FROM --platform=linux/amd64 ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y curl build-essential ca-certificates && rm -rf /var/lib/apt/lists/*
# Install Node 20 via nvm (matching reporter's environment)
ENV NVM_DIR=/root/.nvm
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash && \
. "$NVM_DIR/nvm.sh" && nvm install 20 && nvm alias default 20
ENV PATH="/root/.nvm/versions/node/v20.20.0/bin:$PATH"
# Install wasp-cli and its platform-specific binary.
# npm doesn't auto-install the optional dep when the engine field mismatches,
# so we install the platform package explicitly.
RUN npm install -g @wasp.sh/wasp-cli@0.17 @wasp.sh/wasp-cli-linux-x64-glibc@0.17.2
WORKDIR /home/testuser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment