Skip to content

Dev Container: init.sh fails at pnpm build with "Exec format error" since pnpm 12 #18059

Closed

Description

@ZerglingGo

💡 Summary

Creating or rebuilding the Dev Container fails in .devcontainer/init.sh at pnpm build. pnpm install succeeds, but the first nested pnpm call inside a package script fails with Error launching 'pnpm': Exec format error (os error 8).

This started when packageManager was bumped to pnpm 12 (#17952, 11.25.0 → 12.9.1). It still happens with the current pnpm@12.14.0.

Cause:

  1. The pnpm Dev Container feature installs pnpm 10.10.0 (.devcontainer/devcontainer.json). Inside the repo, it switches to the packageManager version and installs it into ~/.local/share/pnpm/.tools/pnpm/12.14.0.
  2. pnpm 10.10.0 installs it with --allow-build=@pnpm/exe, which blocks the pnpm package's own install script. From pnpm 12 on, that script is what replaces bin/pnpm with the native binary. So bin/pnpm stays a shebang-less shell placeholder.
  3. With shellEmulator: true in pnpm-workspace.yaml, pnpm 12 runs nested pnpm directly, without a shell. Executing the shebang-less placeholder then fails with ENOEXEC.

All three conditions are needed. In my tests, the error did not occur with:

  • pnpm 11.x as the packageManager version
  • shellEmulator off
  • pnpm 10.34.5 or later as the globally installed version
  • corepack
  • the CI flow (pnpm/action-setup@v6)
  • the production Dockerfile, which already runs npm install -g <packageManager>

Dev Container の作成・リビルド時に、.devcontainer/init.sh の pnpm build で失敗します。pnpm install は成功しますが、パッケージスクリプト内で最初にネストして呼ばれる pnpm が Error launching 'pnpm': Exec format error (os error 8) で失敗します。

packageManager が pnpm 12 に更新された時点 (#17952, 11.25.0 → 12.9.1) から発生しており、現在の pnpm@12.14.0 でも再現します。

原因:

  1. pnpm の Dev Container feature は pnpm 10.10.0 をインストールします (.devcontainer/devcontainer.json)。リポジトリ内で実行すると、packageManager のバージョンに切り替えるため、そのバージョンを ~/.local/share/pnpm/.tools/pnpm/12.14.0 にインストールします。
  2. pnpm 10.10.0 はこのインストールを --allow-build=@pnpm/exe 付きで行うため、pnpm パッケージ自身の install スクリプトがブロックされます。pnpm 12 以降は、このスクリプトが bin/pnpm をネイティブバイナリに置き換える仕組みになっているため、bin/pnpm は shebang のないシェルスクリプトのプレースホルダーのまま残ります。
  3. pnpm-workspace.yaml で shellEmulator: true が有効な場合、pnpm 12 はネストした pnpm をシェルを介さず直接実行します。その結果、shebang のないプレースホルダーの実行が ENOEXEC で失敗します。

3 つの条件がすべて揃った場合にのみ発生します。手元の検証では、以下の場合はエラーになりませんでした:

  • packageManager のバージョンが pnpm 11.x の場合
  • shellEmulator が無効の場合
  • グローバルにインストールされた pnpm が 10.34.5 以降の場合
  • corepack を使う場合
  • CI のフロー (pnpm/action-setup@v6)
  • 本番用の Dockerfile (すでに npm install -g <packageManager> を実行している)

🥰 Expected Behavior

init.sh completes, and pnpm build works in the Dev Container.

🤬 Actual Behavior

+ pnpm build
$ pnpm build-pre && pnpm -r build && pnpm build-assets
Error launching 'pnpm': Exec format error (os error 8)
[ELIFECYCLE] Command failed with exit code 1.

📝 Steps to Reproduce

  1. Check out develop. packageManager is pnpm@12.14.0.
  2. Open the repository in the Dev Container ("Rebuild Container" if it already exists).
  3. postCreateCommand (.devcontainer/init.sh) fails at pnpm build with the error above.

💻 Frontend Environment

* Model and OS of the device(s):
* Browser: N/A
* Server URL: N/A
* Misskey: N/A

🛰 Backend Environment (for server admin)

* Installation Method or Hosting Service:
* Misskey: 2026.10.1
* Node: 22.23.1
* PostgreSQL: 18
* Redis: 7
* OS and Architecture: Debian trixie aarch64

Do you want to address this bug yourself?

  • Yes, I will patch the bug myself and send a pull request

Metadata

Metadata

Assignees

No one assigned

    Labels

    ⚠️bug?

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions