Skip to content

unknown error in execFileSync from node:child_process #31710

Closed as duplicate

Description

@davidebombelli

What version of Bun is running?

1.3.14+0d9b296af

What platform is your computer?

Linux 6.8.0-111-generic x86_64 x86_64

What steps can reproduce the bug?

  1. create file test.js with the following content:
import { execFileSync } from 'node:child_process';

const stdout = execFileSync('./helpers/script.sh', ['hello''], {
  encoding: 'utf8',
});

console.log(stdout);
  1. create file ./helpers/script.sh with the following content:
echo "$1 $1";
  1. run it with bun test.js

What is the expected behavior?

in Node.js, it outputs
hello hello

What do you see instead?

in Bun it throws the following error:

1 | import { execFileSync } from 'node:child_process';
2 | 
3 | const stdout = execFileSync('./helpers/script.sh', ['hello'], {
                   ^
ENOEXEC: unknown error, posix_spawn './helpers/script.sh'
      path: "./helpers/script.sh",
   syscall: "spawnSync ./helpers/script.sh",
     errno: -8,
 spawnargs: [ "hello" ],
    signal: null,
    status: undefined,
    output: [ null,
  null, null
],
       pid: undefined,
    stdout: null,
    stderr: null,
      code: "ENOEXEC"

      at spawnSync (node:child_process:226:22)
      at execFileSync (node:child_process:264:54)
      at /home/username/execFileSync.mjs:3:16

Bun v1.3.14 (Linux x64)

Additional information

No response

Activity

  1. robobun commented on Jun 2, 2026

    @robobun
    Collaborator

    ✅ Reproduced — an executable with no shebang makes execve return ENOEXEC; Node/libuv transparently retry the exec through the shell, Bun surfaced the raw error.

    Fix in #31717: on ENOEXEC, re-exec sh <file> <args...> (matching libuv/Node — $0 is the resolved path, $1.. the user args). Covers execFileSync, spawnSync, execFile, Bun.spawn/Bun.spawnSync, and Bun Shell (also fixes #11563).

  2. github-actions commented on Jun 2, 2026

    @github-actions
    Contributor

    Found 1 possible duplicate issue:

    1. bun: Exec format error while executing sh file #11563

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  3. Jarred-Sumner commented on Aug 13, 2026

    @Jarred-Sumner
    Collaborator

    #11563 is the same underlying bug: running an executable script with no shebang makes execve fail with ENOEXEC, and Bun surfaces that instead of retrying through /bin/sh the way Node does (Bun Shell shows it as "Exec format error"). The fix in progress covers spawn/spawnSync/execFileSync as well, so closing this as a duplicate; please follow #11563. Adding #!/bin/sh to the script works around it today.

    Duplicate of #11563

    Please add a 👍 or any extra details over there so it all stays in one place. If this is actually a different problem, say so here and we'll reopen.

    (This comment was written by Claude, on behalf of the Bun team.)

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions