Skip to content

Executable bits are lost on mount(), also after a binary export() #2186

Open

Description

@onmax

Describe the bug

Executable bits don't survive mount(). A file mounted from a FileSystemTree is always mode 644, and the tree has no field for a mode. After chmod 755 inside the container, export(".", { format: "binary" }) and then mount() of that export gives the file back as 644.

Any script in package.json that runs the file directly then fails with jsh: permission denied. A snapshot of node_modules loses every .bin target this way, so the first npm run after mounting it fails.

Symlinks are fine: they survive both the JSON and the binary export.

Link to the blitz that caused the error

https://stackblitz.com/github/onmax/repros/tree/repro/webcontainer-mount-exec-bits/webcontainer-mount-exec-bits-blitz

tool.js is committed as executable (git mode 100755). npm start prints tool.js mode 644, then jsh: permission denied: ./tool.js. The chmod and binary export() round trip through @webcontainer/api is in https://github.com/onmax/repros/tree/repro/webcontainer-mount-exec-bits/webcontainer-mount-exec-bits

Steps to reproduce

  1. mount({ "tool.js": { file: { contents: "#!/usr/bin/env node\nconsole.log('tool ran')" } } }).
  2. ./tool.js exits 126 with jsh: permission denied: ./tool.js.
  3. chmod 755 tool.js (or fs.chmodSync from Node). Now ./tool.js runs.
  4. const data = await wc.export(".", { format: "binary" }), then await wc.mount(data, { mountPoint: "copy" }).
  5. copy/tool.js is mode 644 again, and ./copy/tool.js exits 126.

In the repro: npm install && npm run verify (exits 1 while the bug is there).

Expected behavior

The binary export keeps the mode, so the copy is 755. A FileSystemTree file can also say it is executable, for example { file: { contents, executable: true } } or a mode.

Parity with Local

  • I have run the project in my local machine and I could not reproduce the issue.

Platform

  • OS: Linux
  • Browser: Chromium 159 (headless)
  • Version: @webcontainer/api 1.6.4, container Node v24.22.2

Additional context

My workaround runs one node script after mounting that calls chmodSync on a list of files saved next to the snapshot.

Activity

  1. github-actions commented on Nov 17, 2026

    @github-actions

    We noticed that you did not provide a StackBlitz or Bolt reproduction link. Please update the issue and add a link to a public project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions