Skip to content

EBADF: bad file descriptor - Windows 11 #3563

Closed

Description

@RichardScottOZ

Description

Installed opencode via npm, bun and chocolatey - download of precompiled executable - all have the same behaviour on Windows 11  opencode
ERROR 2025-10-30T00:15:05 +213ms service=default name=Error message=EBADF: bad file descriptor, read stack=Error: EBADF: bad file descriptor, read
    at readFileSync (unknown)
    at _readLocaleFile (../../node_modules/.bun/y18n@5.0.8/node_modules/y18n/build/lib/index.js:135:51)
    at __ (../../node_modules/.bun/y18n@5.0.8/node_modules/y18n/build/lib/index.js:24:18)
    at positional (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/yargs-factory.js:802:81)
    at builder (src/cli/cmd/tui.ts:23:47)
    at applyBuilderUpdateUsageAndParse (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/command.js:174:35)
    at runCommand (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/command.js:164:36)
    at [runYargsParserAndExecuteCommands] (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/yargs-factory.js:1415:93)
    at parse (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/yargs-factory.js:704:29)
    at src/index.ts:89:11
    at asyncModuleEvaluation (native:2)
    at processTicksAndRejections (native:7:39) fatal
Error: Unexpected error, check log file at  for more details

EBADF: bad file descriptor, read
 syscall: "read",
   errno: -9,
    code: "EBADF"

      at readFileSync (unknown:1:1)
      at _readLocaleFile (../../node_modules/.bun/y18n@5.0.8/node_modules/y18n/build/lib/index.js:135:51)
      at __ (../../node_modules/.bun/y18n@5.0.8/node_modules/y18n/build/lib/index.js:24:18)
      at positional (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/yargs-factory.js:802:81)
      at builder (src/cli/cmd/tui.ts:23:47)
      at applyBuilderUpdateUsageAndParse (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/command.js:174:35)
      at runCommand (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/command.js:164:36)
      at [runYargsParserAndExecuteCommands] (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/yargs-factory.js:1415:93)
      at parse (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/yargs-factory.js:704:29)

OpenCode version

15.29

Steps to reproduce

install opencode on windows 11 from this year
try and run it

Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

Windows Terminal, Git Bash - same behaviour

Activity

  1. self-assigned this
    on Oct 30, 2025
  2. rekram1-node commented on Oct 30, 2025

    @rekram1-node
    Contributor

    I will look into this our windows support sucks, needs to be way better, my apologies

  3. RichardScottOZ commented on Nov 1, 2025

    @RichardScottOZ
    Author

    @rekram1-node - if you want anything tested, let me know. I did try several recent versions too to check - same behaviour. Tried a lot of things - symlinks, aliases of git bash shells, paths, env var or whatever, no luck - so probably needs solving at a lower level in whatever that interplay of local, assuming shells and bun even if you don't have it from someone that understands that part well.

  4. rekram1-node commented on Nov 1, 2025

    @rekram1-node
    Contributor

    sounds good, I did just setup a windows 11 vm so I will start testing in it more

  5. aaron-cardenas commented on Dec 9, 2025

    @aaron-cardenas

    same for me on win 10:

    c:\wamp\www\Comunal>scoop install extras/opencode
    Installing 'opencode' (1.0.134) [64bit] from 'extras' bucket
    Loading opencode-windows-x64.zip from cache
    Checking hash of opencode-windows-x64.zip ... ok.
    Extracting opencode-windows-x64.zip ... done.
    Linking ~\scoop\apps\opencode\current => ~\scoop\apps\opencode\1.0.134
    Creating shim for 'opencode'.
    Creating shortcut for OpenCode (opencode.exe)
    'opencode' (1.0.134) was installed successfully!

    c:\wamp\www\Comunal>opencode
    ERROR 2025-12-09T00:50:18 +388ms service=default name=Error message=EBADF: bad file descriptor, read stack=Error: EBADF: bad file descriptor, read
    at readFileSync (unknown)
    at _readLocaleFile (../../node_modules/.bun/y18n@5.0.8/node_modules/y18n/build/lib/index.js:135:51)
    at __ (../../node_modules/.bun/y18n@5.0.8/node_modules/y18n/build/lib/index.js:24:18)
    at positional (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/yargs-factory.js:802:81)
    at builder (src/cli/cmd/tui/thread.ts:19:8)
    at applyBuilderUpdateUsageAndParse (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/command.js:174:35)
    at runCommand (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/command.js:164:36)
    at [runYargsParserAndExecuteCommands] (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/yargs-factory.js:1415:93)
    at parse (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/yargs-factory.js:704:29)
    at src/index.ts:111:13
    at asyncModuleEvaluation (native:2)
    at processTicksAndRejections (native:7:39) fatal
    Error: Unexpected error, check log file at for more details

    EBADF: bad file descriptor, read
    syscall: "read",
    errno: -9,
    code: "EBADF"

      at readFileSync (unknown:1:1)
      at _readLocaleFile (../../node_modules/.bun/y18n@5.0.8/node_modules/y18n/build/lib/index.js:135:51)
      at __ (../../node_modules/.bun/y18n@5.0.8/node_modules/y18n/build/lib/index.js:24:18)
      at positional (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/yargs-factory.js:802:81)
      at builder (src/cli/cmd/tui/thread.ts:19:8)
      at applyBuilderUpdateUsageAndParse (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/command.js:174:35)
      at runCommand (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/command.js:164:36)
      at [runYargsParserAndExecuteCommands] (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/yargs-factory.js:1415:93)
      at parse (../../node_modules/.bun/yargs@18.0.0/node_modules/yargs/build/lib/yargs-factory.js:704:29)
    

    c:\wamp\www\Comunal>scoop uninstall extras/opencode
    Uninstalling 'opencode' (1.0.134).
    Removing shim 'opencode.shim'.
    Removing shim 'opencode.exe'.
    Removing shortcut ~\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Scoop Apps\OpenCode.lnk
    Unlinking ~\scoop\apps\opencode\current
    'opencode' was uninstalled.

  6. rekram1-node commented on Dec 9, 2025

    @rekram1-node
    Contributor

    Does that happen w/ all install methods for you?

  7. aaron-cardenas commented on Dec 9, 2025

    @aaron-cardenas

    I tried the installation with npm, Scup and again with Chocolatey, got the same error.

  8. AlexanderVoid45 commented on Jan 18, 2026

    @AlexanderVoid45

    same for me at 1 of my pc`s of 2(where ive tried opencode). have same setup, same antimalvare.

  9. AlexanderVoid45 commented on Jan 22, 2026

    @AlexanderVoid45

    Found the fix

    The issue is in y18n library - it tries to readFileSync locale files, which fails with EBADF/EUNKNOWN in Bun compiled binaries on Windows.

    Solution

    Add patch file patches/y18n@5.0.8.patch:

    diff --git a/build/lib/index.js b/build/lib/index.js
    --- a/build/lib/index.js
    +++ b/build/lib/index.js
    @@ -139,7 +139,7 @@ class Y18N {
             if (err instanceof SyntaxError) {
                 err.message = 'syntax error in ' + languageFile;
             }
    -        if (err.code === 'ENOENT')
    +        if (err.code === 'ENOENT' || err.code === 'EBADF' || err.code === 'EUNKNOWN')
                 localeLookup = {};
             else
                 throw err;

    And add to package.json:

    "patchedDependencies": {
      "y18n@5.0.8": "patches/y18n@5.0.8.patch"
    }

    Tested on Windows 11 (22000.2538) - both CLI and desktop work after this fix.

  10. github-actions commented on Mar 26, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  11. RichardScottOZ commented on Mar 26, 2026

    @RichardScottOZ
    Author

    Is this going to be built in?

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwindows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions