Skip to content

Bun.spawn throws incorrect ENOENT error when cwd does not exist #24012

Closed as duplicate

Description

@veracioux

What version of Bun is running?

1.3.0+b0a6feca5

What platform is your computer?

Linux 6.17.1-arch1-1 x86_64 unknown

What steps can reproduce the bug?

Run

bun -e 'Bun.spawn(["/bin/echo"], { cwd:"/nonexistent" })'

What is the expected behavior?

Indicate that the directory /nonexistent does not exist.

1 | Bun.spawn(["/bin/echo"], { cwd:"/nonexistent" })
        ^
ENOENT: no such file or directory, posix_spawn '/nonexistent'
    path: "/nonexistent",
 syscall: "posix_spawn",
   errno: -2,
    code: "ENOENT"

      at /home/haris/[eval]:1:5
      at loadAndEvaluateModule (2:1)

Bun v1.3.0 (Linux x64)

What do you see instead?

It complains that the executable /bin/echo does not exist, but it does.

1 | Bun.spawn(["/bin/echo"], {cwd:"/nonexistent"})
        ^
ENOENT: no such file or directory, posix_spawn '/bin/echo'
    path: "/bin/echo",
 syscall: "posix_spawn",
   errno: -2,
    code: "ENOENT"

      at /home/haris/[eval]:1:5
      at loadAndEvaluateModule (2:1)

Bun v1.3.0 (Linux x64)

Additional information

I might take a stab at fixing it if I can set up my development environment and no one beats me to it.

Activity

  1. github-actions commented on Oct 23, 2025

    @github-actions
    Contributor

    Found 2 possible duplicate issues:

    1. Bun.spawn with cwd that doesn't exist returns confusing error message #14535
    2. Bun.spawn with a non-existant cwd prints error with wrong path #8024

    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

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