EBADF: bad file descriptor - Windows 11 #2358

Open
opened 2026-02-16 17:35:18 -05:00 by yindo · 8 comments
Owner

Originally created by @RichardScottOZ on GitHub (Oct 30, 2025).

Originally assigned to: @rekram1-node on GitHub.

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

Originally created by @RichardScottOZ on GitHub (Oct 30, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description ```python 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
yindo added the windowsbug labels 2026-02-16 17:35:18 -05:00
Author
Owner

@rekram1-node commented on GitHub (Oct 30, 2025):

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

@rekram1-node commented on GitHub (Oct 30, 2025): I will look into this our windows support sucks, needs to be way better, my apologies
Author
Owner

@RichardScottOZ commented on GitHub (Nov 1, 2025):

@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.

@RichardScottOZ commented on GitHub (Nov 1, 2025): @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.
Author
Owner

@rekram1-node commented on GitHub (Nov 1, 2025):

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

@rekram1-node commented on GitHub (Nov 1, 2025): sounds good, I did just setup a windows 11 vm so I will start testing in it more
Author
Owner

@aaron-cardenas commented on GitHub (Dec 8, 2025):

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.

@aaron-cardenas commented on GitHub (Dec 8, 2025): 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.
Author
Owner

@rekram1-node commented on GitHub (Dec 8, 2025):

Does that happen w/ all install methods for you?

@rekram1-node commented on GitHub (Dec 8, 2025): Does that happen w/ all install methods for you?
Author
Owner

@aaron-cardenas commented on GitHub (Dec 9, 2025):

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

@aaron-cardenas commented on GitHub (Dec 9, 2025): I tried the installation with npm, Scup and again with Chocolatey, got the same error.
Author
Owner

@AlexanderVoid45 commented on GitHub (Jan 18, 2026):

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

@AlexanderVoid45 commented on GitHub (Jan 18, 2026): same for me at 1 of my pc`s of 2(where ive tried opencode). have same setup, same antimalvare.
Author
Owner

@AlexanderVoid45 commented on GitHub (Jan 22, 2026):

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.

@AlexanderVoid45 commented on GitHub (Jan 22, 2026): ## 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 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`: ```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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2358