Skip to content

Failed to initialize OpenTUI render library: Failed to open library. #3765

Closed

Description

@devahmedshendy

Description

I just installed opencode and failed to start it for first time

❯ opencode
9971 |   onAnyNativeEvent(handler) {
9972 |     this._anyEventHandlers.push(handler);
9973 |   }
9974 | }
9975 | var opentuiLibPath;
9976 | var opentuiLib;
           ^
error: Failed to initialize OpenTUI render library: Failed to open library. This is usually caused by a missing library or an invalid library path.
      at resolveRenderLib (../../node_modules/.bun/@opentui+core@0.1.32+81ecd8642a1892ca/node_modules/@opentui/core/index-3f9h747j.js:9976:5)
      at createCliRenderer (../../node_modules/.bun/@opentui+core@0.1.32+81ecd8642a1892ca/node_modules/@opentui/core/index-3f9h747j.js:12441:3)
      at createCliRenderer (../../node_modules/.bun/@opentui+core@0.1.32+81ecd8642a1892ca/node_modules/@opentui/core/index-3f9h747j.js:12432:28)
      at <anonymous> (../../node_modules/.bun/@opentui+solid@0.1.32+1753ef9b65046169/node_modules/@opentui/solid/index.js:893:1)
      at render (../../node_modules/.bun/@opentui+solid@0.1.32+1753ef9b65046169/node_modules/@opentui/solid/index.js:892:7)
      at <anonymous> (src/cli/cmd/tui/app.tsx:95:7)

Whether I install is using brew, bun, npm .. I get same result.

OpenCode version

1.0.11

Steps to reproduce

> bun add -g opencode-ai
> opencode

Screenshot and/or share link

No response

Operating System

macOS 15.7.1 (24G231)

Terminal

fishshell

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Nov 2, 2025
  2. github-actions commented on Nov 2, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    The "Failed to initialize OpenTUI render library" error suggests missing system-level dependencies, which is exactly what these issues track. Your specific platform details (OS, distribution, installation method) would help determine if this is the same underlying problem.

    Feel free to ignore if none of these address your specific case.

  3. guoqiao commented on Nov 2, 2025

    @guoqiao

    +1, I also get this error after upgrade.

  4. thdxr commented on Nov 3, 2025

    @thdxr
    Member

    what cpu do you have

  5. guoqiao commented on Nov 3, 2025

    @guoqiao

    what cpu do you have

    I am using opencode on a home server with old i5 cpu:

    CPU: Intel i5-9400F (6) @ 4.100GHz
    OS: Ubuntu 24.04.3 LTS x86_64

    PS:

    • I tried all v1.0.0+ versions, with different ways to install (curl/zip/bun/brew), the same Failed to initialize OpenTUI render library error happened.
    • I also tried to install opentui with bun separately, still no help.
    • I have tried to remove old vesion completely and re-install, no help either.

    I have downgraded to v0.15.31 (the last version before v1.0.0) and get it working for now.

  6. youngtai commented on Nov 3, 2025

    @youngtai

    Same error but thrown in a different place:

    10033 | function resolveRenderLib() {
    10034 |   if (!opentuiLib) {
    10035 |     try {
    10036 |       opentuiLib = new FFIRenderLib(opentuiLibPath);
    10037 |     } catch (error) {
    10038 |       throw new Error(`Failed to initialize OpenTUI render library: ${error instanceof Error ? error.message : "Unknown error"}`);
                        ^
    error: Failed to initialize OpenTUI render library: Failed to open library "/$bunfs/root/libopentui-24nfw5wz.dylib": dlopen(/$bunfs/root/libopentui-24nfw5wz.dylib, 0x0001): tried: '/$bunfs/root/libopentui-24nfw5wz.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/$bunfs/root/libopentui-24nfw5wz.dylib' (no such file), '/$bunfs/root/libopentui-24nfw5wz.dylib' (no such file)
          at resolveRenderLib (../../node_modules/.bun/@opentui+core@0.1.33+81ecd8642a1892ca/node_modules/@opentui/core/index-xqg0a6ka.js:10038:13)
          at createCliRenderer (../../node_modules/.bun/@opentui+core@0.1.33+81ecd8642a1892ca/node_modules/@opentui/core/index-xqg0a6ka.js:12508:18)
          at createCliRenderer (../../node_modules/.bun/@opentui+core@0.1.33+81ecd8642a1892ca/node_modules/@opentui/core/index-xqg0a6ka.js:12499:34)
          at <anonymous> (../../node_modules/.bun/@opentui+solid@0.1.33+1753ef9b65046169/node_modules/@opentui/solid/index.js:904:26)
          at render (../../node_modules/.bun/@opentui+solid@0.1.33+1753ef9b65046169/node_modules/@opentui/solid/index.js:903:21)
          at <anonymous> (src/cli/cmd/tui/app.tsx:101:5)
    

    Tried installing with the install script and npm - both same results.

    Device: M4 Pro MBP
    Opencode version: 1.0.18

  7. thdxr commented on Nov 4, 2025

    @thdxr
    Member

    if you have this error on mac does this work touch $TMPDIR/test.dylib

  8. ErSoul commented on Nov 4, 2025

    @ErSoul

    I'm having this same error for windows. Same result from NPM & the bash script with curl; and for git-bash, cmd, and powershell.

    Image
  9. devahmedshendy commented on Nov 4, 2025

    @devahmedshendy
    Author

    @thdxr it is not allowed:

    ❯ touch $TMPDIR/test.dylib
    touch: /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T//test.dylib: Permission denied
    
  10. thdxr commented on Nov 4, 2025

    @thdxr
    Member

    hm wonder why this is the case

    CleanShot 2025-11-04 at 00.10.09@2x.png

  11. thdxr commented on Nov 4, 2025

    @thdxr
    Member

    TMPDIR=/tmp opencode

    this doesn't work either right?

  12. devahmedshendy commented on Nov 4, 2025

    @devahmedshendy
    Author

    @thdxr no no it works when running TMPDIR=/tmp opencode, that's it, can it work without issues after that?

    Image
    ❯ echo $TMPDIR
    /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/
    
    ❯ ls -ld $TMPDIR
    drwx------  64 root  wheel  2048 Nov  4 06:53 /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T//
    
    ❯ whoami
    **** my username
    
  13. devahmedshendy commented on Nov 4, 2025

    @devahmedshendy
    Author

    btw, I didn't run any command in any restricted context, just open normal terminal and use it.

  14. 5 remaining items

  15. devahmedshendy commented on Nov 19, 2025

    @devahmedshendy
    Author

    I noticed the issue is no more happening in version 1.0.68. I can open opencode safely without the error reported in this issue.
    I will close the issue, and me or anyone can reopen it once I issue arise again.

  16. apdt commented on Nov 19, 2025

    @apdt

    I'm seeing this issue on 1.0.78:

    $ opencode 
    ^[\10486 | function resolveRenderLib() {
    10487 |   if (!opentuiLib) {
    10488 |     try {
    10489 |       opentuiLib = new FFIRenderLib(opentuiLibPath);
    10490 |     } catch (error) {
    10491 |       throw new Error(`Failed to initialize OpenTUI render library: ${error instanceof Error ? error.message : "Unknown error"}`);
                        ^
    error: Failed to initialize OpenTUI render library: Failed to open library "/tmp/.fa797eeecf37f6f5-00000001.so": /tmp/.fa797eeecf37f6f5-00000001.so: failed to map segment from shared object
          at resolveRenderLib (../../node_modules/.bun/@opentui+core@0.1.41+81ecd8642a1892ca/node_modules/@opentui/core/index-kj9k00yt.js:10491:13)
          at createCliRenderer (../../node_modules/.bun/@opentui+core@0.1.41+81ecd8642a1892ca/node_modules/@opentui/core/index-kj9k00yt.js:12993:18)
          at createCliRenderer (../../node_modules/.bun/@opentui+core@0.1.41+81ecd8642a1892ca/node_modules/@opentui/core/index-kj9k00yt.js:12984:34)
          at <anonymous> (../../node_modules/.bun/@opentui+solid@0.1.41+1753ef9b65046169/node_modules/@opentui/solid/index.js:904:26)
          at render (../../node_modules/.bun/@opentui+solid@0.1.41+1753ef9b65046169/node_modules/@opentui/solid/index.js:903:21)
          at <anonymous> (src/cli/cmd/tui/app.tsx:102:5)
    

    After a little testing, I tried forcing TMPDIR, with debug logging and it doesn't appear to be respecting the TMPDIR value and seems hardwired to use /tmp which in our org is mounted (rw,nosuid,nodev,noexec,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota) :

    $ TMPDIR=~/tmp2 opencode --print-logs --log-level DEBUG
    INFO  2025-11-19T15:49:09 +222ms service=default version=1.0.78 args=["--print-logs","--log-level","DEBUG"] opencode
    ^[\ERROR 2025-11-19T15:49:10 +375ms service=acp-command promise={} reason=Failed to initialize OpenTUI render library: Failed to open library "/tmp/.d97d732dff7fbff3-00000001.so": /tmp/.d97d732dff7fbff3-00000001.so: failed to map segment from shared object Unhandled rejection
    ERROR 2025-11-19T15:49:10 +0ms service=default e=Failed to initialize OpenTUI render library: Failed to open library "/tmp/.d97d732dff7fbff3-00000001.so": /tmp/.d97d732dff7fbff3-00000001.so: failed to map segment from shared object rejection
    ERROR 2025-11-19T15:49:10 +0ms service=default Error: Failed to initialize OpenTUI render library: Failed to open library "/tmp/.d97d732dff7fbff3-00000001.so": /tmp/.d97d732dff7fbff3-00000001.so: failed to map segment from shared object
    
  17. Universal-Invariant commented on Nov 19, 2025

    @Universal-Invariant

    I noticed the issue is no more happening in version 1.0.68. I can open opencode safely without the error reported in this issue. I will close the issue, and me or anyone can reopen it once I issue arise again.

    It should then be easy to track down to figure out what it could have been? Better if someone could figure out what the likely cause was for the future since it might return.

    I just updated to v1.0.49 -> v1.0.78 and I get no TUI or warning now or anything. Just sits there in the terminal without returning to it unless I ctrl-z. This is on windows 24H2.

    For me, the issue starts with the v1.0.0 TUI rewrite. v0.15.31 works fine. v1.0.0 TUI rewrite gives:

    10033 | function resolveRenderLib() {
    10034 |   if (!opentuiLib) {
    10035 |     try {
    10036 |       opentuiLib = new FFIRenderLib(opentuiLibPath);
    10037 |     } catch (error) {
    10038 |       throw new Error(`Failed to initialize OpenTUI render library: ${error instanceof Error ? error.message : "Unknown error"}`);
                        ^
    error: Failed to initialize OpenTUI render library: Failed to open library "B:/~BUN/root/opentui-8b8p1y9r.dll": error code 126
          at resolveRenderLib (../../node_modules/.bun/@opentui+core@0.1.33+81ecd8642a1892ca/node_modules/@opentui/core/index-xqg0a6ka.js:10038:13)
          at createCliRenderer (../../node_modules/.bun/@opentui+core@0.1.33+81ecd8642a1892ca/node_modules/@opentui/core/index-xqg0a6ka.js:12508:18)
          at createCliRenderer (../../node_modules/.bun/@opentui+core@0.1.33+81ecd8642a1892ca/node_modules/@opentui/core/index-xqg0a6ka.js:12499:34)
          at <anonymous> (../../node_modules/.bun/@opentui+solid@0.1.33+1753ef9b65046169/node_modules/@opentui/solid/index.js:904:26)
          at render (../../node_modules/.bun/@opentui+solid@0.1.33+1753ef9b65046169/node_modules/@opentui/solid/index.js:903:21)
          at <anonymous> (src/cli/cmd/tui/app.tsx:103:5)
    
  18. Universal-Invariant commented on Nov 19, 2025

    @Universal-Invariant

    I'm seeing this issue on 1.0.78:

    $ opencode 
    ^[\10486 | function resolveRenderLib() {
    10487 |   if (!opentuiLib) {
    10488 |     try {
    10489 |       opentuiLib = new FFIRenderLib(opentuiLibPath);
    10490 |     } catch (error) {
    10491 |       throw new Error(`Failed to initialize OpenTUI render library: ${error instanceof Error ? error.message : "Unknown error"}`);
                        ^
    error: Failed to initialize OpenTUI render library: Failed to open library "/tmp/.fa797eeecf37f6f5-00000001.so": /tmp/.fa797eeecf37f6f5-00000001.so: failed to map segment from shared object
          at resolveRenderLib (../../node_modules/.bun/@opentui+core@0.1.41+81ecd8642a1892ca/node_modules/@opentui/core/index-kj9k00yt.js:10491:13)
          at createCliRenderer (../../node_modules/.bun/@opentui+core@0.1.41+81ecd8642a1892ca/node_modules/@opentui/core/index-kj9k00yt.js:12993:18)
          at createCliRenderer (../../node_modules/.bun/@opentui+core@0.1.41+81ecd8642a1892ca/node_modules/@opentui/core/index-kj9k00yt.js:12984:34)
          at <anonymous> (../../node_modules/.bun/@opentui+solid@0.1.41+1753ef9b65046169/node_modules/@opentui/solid/index.js:904:26)
          at render (../../node_modules/.bun/@opentui+solid@0.1.41+1753ef9b65046169/node_modules/@opentui/solid/index.js:903:21)
          at <anonymous> (src/cli/cmd/tui/app.tsx:102:5)
    

    After a little testing, I tried forcing TMPDIR, with debug logging and it doesn't appear to be respecting the TMPDIR value and seems hardwired to use /tmp which in our org is mounted (rw,nosuid,nodev,noexec,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota) :

    $ TMPDIR=~/tmp2 opencode --print-logs --log-level DEBUG
    INFO  2025-11-19T15:49:09 +222ms service=default version=1.0.78 args=["--print-logs","--log-level","DEBUG"] opencode
    ^[\ERROR 2025-11-19T15:49:10 +375ms service=acp-command promise={} reason=Failed to initialize OpenTUI render library: Failed to open library "/tmp/.d97d732dff7fbff3-00000001.so": /tmp/.d97d732dff7fbff3-00000001.so: failed to map segment from shared object Unhandled rejection
    ERROR 2025-11-19T15:49:10 +0ms service=default e=Failed to initialize OpenTUI render library: Failed to open library "/tmp/.d97d732dff7fbff3-00000001.so": /tmp/.d97d732dff7fbff3-00000001.so: failed to map segment from shared object rejection
    ERROR 2025-11-19T15:49:10 +0ms service=default Error: Failed to initialize OpenTUI render library: Failed to open library "/tmp/.d97d732dff7fbff3-00000001.so": /tmp/.d97d732dff7fbff3-00000001.so: failed to map segment from shared object
    

    and hasn't worked since v1.0.0 for me on windows. It's very likely there are some hard coded paths or assumptions made which is causing the same error on windows. E.g., there is no /tmp on windows and if yours is blocked and it's assuming /tmp then that could explain the problem. But this goes back to v1.0.0 for me so

     opencode --print-logs --log-level DEBUG
    INFO  2025-11-19T16:08:20 +104ms service=default version=1.0.78 args=["--print-logs","--log-level","DEBUG"] opencode
    ERROR 2025-11-19T16:08:20 +147ms service=acp-command promise={} reason=Failed to initialize OpenTUI render library: Failed to open library "B:/~BUN/root/opentui-t13tdp88.dll": error code 126 Unhandled rejection
    ERROR 2025-11-19T16:08:20 +0ms service=default e=Failed to initialize OpenTUI render library: Failed to open library "B:/~BUN/root/opentui-t13tdp88.dll": error code 126 rejection
    ERROR 2025-11-19T16:08:20 +0ms service=default Error: Failed to initialize OpenTUI render library: Failed to open library "B:/~BUN/root/opentui-t13tdp88.dll": error code 126
    

    I don't know why anyone is hard coding paths, even if it is just in the output, in this day and age. v1.0.77 looks like someone just removed displaying the error on windows since it just hangs without any error but with print-logs it shows that it has the same problem.

  19. apdt commented on Nov 19, 2025

    @apdt

    I'm seeing this issue on 1.0.78:

    $ opencode 
    ^[\10486 | function resolveRenderLib() {
    10487 |   if (!opentuiLib) {
    10488 |     try {
    10489 |       opentuiLib = new FFIRenderLib(opentuiLibPath);
    10490 |     } catch (error) {
    10491 |       throw new Error(`Failed to initialize OpenTUI render library: ${error instanceof Error ? error.message : "Unknown error"}`);
                        ^
    error: Failed to initialize OpenTUI render library: Failed to open library "/tmp/.fa797eeecf37f6f5-00000001.so": /tmp/.fa797eeecf37f6f5-00000001.so: failed to map segment from shared object
          at resolveRenderLib (../../node_modules/.bun/@opentui+core@0.1.41+81ecd8642a1892ca/node_modules/@opentui/core/index-kj9k00yt.js:10491:13)
          at createCliRenderer (../../node_modules/.bun/@opentui+core@0.1.41+81ecd8642a1892ca/node_modules/@opentui/core/index-kj9k00yt.js:12993:18)
          at createCliRenderer (../../node_modules/.bun/@opentui+core@0.1.41+81ecd8642a1892ca/node_modules/@opentui/core/index-kj9k00yt.js:12984:34)
          at <anonymous> (../../node_modules/.bun/@opentui+solid@0.1.41+1753ef9b65046169/node_modules/@opentui/solid/index.js:904:26)
          at render (../../node_modules/.bun/@opentui+solid@0.1.41+1753ef9b65046169/node_modules/@opentui/solid/index.js:903:21)
          at <anonymous> (src/cli/cmd/tui/app.tsx:102:5)
    

    After a little testing, I tried forcing TMPDIR, with debug logging and it doesn't appear to be respecting the TMPDIR value and seems hardwired to use /tmp which in our org is mounted (rw,nosuid,nodev,noexec,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota) :

    $ TMPDIR=~/tmp2 opencode --print-logs --log-level DEBUG
    INFO  2025-11-19T15:49:09 +222ms service=default version=1.0.78 args=["--print-logs","--log-level","DEBUG"] opencode
    ^[\ERROR 2025-11-19T15:49:10 +375ms service=acp-command promise={} reason=Failed to initialize OpenTUI render library: Failed to open library "/tmp/.d97d732dff7fbff3-00000001.so": /tmp/.d97d732dff7fbff3-00000001.so: failed to map segment from shared object Unhandled rejection
    ERROR 2025-11-19T15:49:10 +0ms service=default e=Failed to initialize OpenTUI render library: Failed to open library "/tmp/.d97d732dff7fbff3-00000001.so": /tmp/.d97d732dff7fbff3-00000001.so: failed to map segment from shared object rejection
    ERROR 2025-11-19T15:49:10 +0ms service=default Error: Failed to initialize OpenTUI render library: Failed to open library "/tmp/.d97d732dff7fbff3-00000001.so": /tmp/.d97d732dff7fbff3-00000001.so: failed to map segment from shared object
    

    and hasn't worked since v1.0.0 for me on windows. It's very likely there are some hard coded paths or assumptions made which is causing the same error on windows. E.g., there is no /tmp on windows and if yours is blocked and it's assuming /tmp then that could explain the problem. But this goes back to v1.0.0 for me so

     opencode --print-logs --log-level DEBUG
    INFO  2025-11-19T16:08:20 +104ms service=default version=1.0.78 args=["--print-logs","--log-level","DEBUG"] opencode
    ERROR 2025-11-19T16:08:20 +147ms service=acp-command promise={} reason=Failed to initialize OpenTUI render library: Failed to open library "B:/~BUN/root/opentui-t13tdp88.dll": error code 126 Unhandled rejection
    ERROR 2025-11-19T16:08:20 +0ms service=default e=Failed to initialize OpenTUI render library: Failed to open library "B:/~BUN/root/opentui-t13tdp88.dll": error code 126 rejection
    ERROR 2025-11-19T16:08:20 +0ms service=default Error: Failed to initialize OpenTUI render library: Failed to open library "B:/~BUN/root/opentui-t13tdp88.dll": error code 126
    

    I don't know why anyone is hard coding paths, even if it is just in the output in this day and age. In the since v1.0.77 it seems someone just removed displaying the error on windows since it just hangs without any error.

    So after some searching, for me, 1.0.56 does not work and 1.0.55 does work. This should help identify the cause for my issue, but probably doesn't help what @Universal-Invariant is seeing though might point to something?

  20. Universal-Invariant commented on Nov 19, 2025

    @Universal-Invariant

    I'm seeing this issue on 1.0.78:

    $ opencode 
    ^[\10486 | function resolveRenderLib() {
    10487 |   if (!opentuiLib) {
    10488 |     try {
    10489 |       opentuiLib = new FFIRenderLib(opentuiLibPath);
    10490 |     } catch (error) {
    10491 |       throw new Error(`Failed to initialize OpenTUI render library: ${error instanceof Error ? error.message : "Unknown error"}`);
                        ^
    error: Failed to initialize OpenTUI render library: Failed to open library "/tmp/.fa797eeecf37f6f5-00000001.so": /tmp/.fa797eeecf37f6f5-00000001.so: failed to map segment from shared object
          at resolveRenderLib (../../node_modules/.bun/@opentui+core@0.1.41+81ecd8642a1892ca/node_modules/@opentui/core/index-kj9k00yt.js:10491:13)
          at createCliRenderer (../../node_modules/.bun/@opentui+core@0.1.41+81ecd8642a1892ca/node_modules/@opentui/core/index-kj9k00yt.js:12993:18)
          at createCliRenderer (../../node_modules/.bun/@opentui+core@0.1.41+81ecd8642a1892ca/node_modules/@opentui/core/index-kj9k00yt.js:12984:34)
          at <anonymous> (../../node_modules/.bun/@opentui+solid@0.1.41+1753ef9b65046169/node_modules/@opentui/solid/index.js:904:26)
          at render (../../node_modules/.bun/@opentui+solid@0.1.41+1753ef9b65046169/node_modules/@opentui/solid/index.js:903:21)
          at <anonymous> (src/cli/cmd/tui/app.tsx:102:5)
    

    After a little testing, I tried forcing TMPDIR, with debug logging and it doesn't appear to be respecting the TMPDIR value and seems hardwired to use /tmp which in our org is mounted (rw,nosuid,nodev,noexec,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota) :

    $ TMPDIR=~/tmp2 opencode --print-logs --log-level DEBUG
    INFO  2025-11-19T15:49:09 +222ms service=default version=1.0.78 args=["--print-logs","--log-level","DEBUG"] opencode
    ^[\ERROR 2025-11-19T15:49:10 +375ms service=acp-command promise={} reason=Failed to initialize OpenTUI render library: Failed to open library "/tmp/.d97d732dff7fbff3-00000001.so": /tmp/.d97d732dff7fbff3-00000001.so: failed to map segment from shared object Unhandled rejection
    ERROR 2025-11-19T15:49:10 +0ms service=default e=Failed to initialize OpenTUI render library: Failed to open library "/tmp/.d97d732dff7fbff3-00000001.so": /tmp/.d97d732dff7fbff3-00000001.so: failed to map segment from shared object rejection
    ERROR 2025-11-19T15:49:10 +0ms service=default Error: Failed to initialize OpenTUI render library: Failed to open library "/tmp/.d97d732dff7fbff3-00000001.so": /tmp/.d97d732dff7fbff3-00000001.so: failed to map segment from shared object
    

    and hasn't worked since v1.0.0 for me on windows. It's very likely there are some hard coded paths or assumptions made which is causing the same error on windows. E.g., there is no /tmp on windows and if yours is blocked and it's assuming /tmp then that could explain the problem. But this goes back to v1.0.0 for me so

     opencode --print-logs --log-level DEBUG
    INFO  2025-11-19T16:08:20 +104ms service=default version=1.0.78 args=["--print-logs","--log-level","DEBUG"] opencode
    ERROR 2025-11-19T16:08:20 +147ms service=acp-command promise={} reason=Failed to initialize OpenTUI render library: Failed to open library "B:/~BUN/root/opentui-t13tdp88.dll": error code 126 Unhandled rejection
    ERROR 2025-11-19T16:08:20 +0ms service=default e=Failed to initialize OpenTUI render library: Failed to open library "B:/~BUN/root/opentui-t13tdp88.dll": error code 126 rejection
    ERROR 2025-11-19T16:08:20 +0ms service=default Error: Failed to initialize OpenTUI render library: Failed to open library "B:/~BUN/root/opentui-t13tdp88.dll": error code 126
    

    I don't know why anyone is hard coding paths, even if it is just in the output in this day and age. In the since v1.0.77 it seems someone just removed displaying the error on windows since it just hangs without any error.

    So after some searching, for me, 1.0.56 does not work and 1.0.55 does work. This should help identify the cause for my issue, but probably doesn't help what @Universal-Invariant is seeing though might point to something?

    https://github.com/sst/opentui/blob/8e307896a463321df881b7f68348954eca9014dc/packages/core/src/zig.ts#L2910

    This is the code that is outputting the error. What could solve this very quickly is some way to set the opentui path to use from the command line. Then we can at least force it. I downloaded the opentui.dll for windows. I thought about creating that path putting it in there and it might work if there are not version issues but it wouldn't really solve the problem. I could also use procmon to determine if it is actually looking for the file there but I think someone who can easily patch this needs to look at it. Again, the easiest way would be to somehow allow us to configure the openTUI path. I have no B drive so where it is getting B from is ridiculous. Someone said it was just something hard coded and irrelevant but looking at the code suggests otherwise.

  21. pmarreck commented on Nov 22, 2025

    @pmarreck

    A few cross-platform notes about TMPDIR and mktemp that may be relevant, which I encountered:

    1. Linux /tmp is almost always an ephemeral RAMdisk via being formatted as tmpfs.

    2. Mac mktemp by default returns a file or directory of the form /var/folders/xx/yyyyyyyy/... which is a user-specific directory that cannot be accessed by other users; this design was for security reasons; to my knowledge, it is stored on your SSD (and thus wears it down over time) and not in RAM. It will do this regardless of what TMPDIR is set to, unless you specify $TMPDIR as part of the template argument to mktemp, or pass --tmpdir to it (see below).

    3. On my Mac, I added a setup that puts /tmp on a RAMdisk when I log in, so I can enjoy the advantages of not wearing down my SSD, but there's a catch: /tmp is symlinked to /private/tmp.

    As a result of all of the above, and because I'm more concerned about SSD wear than other users (of which there are none set up on my laptops besides me) having access to my tmpfiles, here is my cross-platform dotfile setup for TMPDIR:

    export TMPDIR="/tmp/$$" # a canonical process-ID-specific temp directory
    mkdir -p "$TMPDIR" # because mktemp won't work unless it already exists
    export TMPDIR=$(realpath "$TMPDIR") # to resolve to the physical path
    

    To convince mktemp, gmktemp (the GNU version, if you're on Mac and it's installed) to actually USE TMPDIR, you can pass --tmpdir to it when you call it.

  22. Universal-Invariant commented on Nov 22, 2025

    @Universal-Invariant

    A few cross-platform notes about TMPDIR and mktemp that may be relevant, which I encountered:

    1. Linux /tmp is almost always an ephemeral RAMdisk via being formatted as tmpfs.
    2. Mac mktemp by default returns a file or directory of the form /var/folders/xx/yyyyyyyy/... which is a user-specific directory that cannot be accessed by other users; this design was for security reasons; to my knowledge, it is stored on your SSD (and thus wears it down over time) and not in RAM. It will do this regardless of what TMPDIR is set to, unless you specify $TMPDIR as part of the template argument to mktemp, or pass --tmpdir to it (see below).
    3. On my Mac, I added a setup that puts /tmp on a RAMdisk when I log in, so I can enjoy the advantages of not wearing down my SSD, but there's a catch: /tmp is symlinked to /private/tmp.

    As a result of all of the above, and because I'm more concerned about SSD wear than other users (of which there are none set up on my laptops besides me) having access to my tmpfiles, here is my cross-platform dotfile setup for TMPDIR:

    export TMPDIR="/tmp/$$" # a canonical process-ID-specific temp directory
    mkdir -p "$TMPDIR" # because mktemp won't work unless it already exists
    export TMPDIR=$(realpath "$TMPDIR") # to resolve to the physical path
    

    To convince mktemp, gmktemp (the GNU version, if you're on Mac and it's installed) to actually USE TMPDIR, you can pass --tmpdir to it when you call it.

    On windows I essentially do the same where I have a ramdisk using AIM toolkit. I recently switched over from ImDisk because ImDisk has a bug in it which causes some programs to error out when accessing Temp. The error is rare enough that I don't know if it solves it or not I saw someone mention that it did.

    In any case, this doesn't seem to be the problem with opencode AFAICT. At least on windows it seems it cannot find the opentui library as it is looking at it in a hardcoded or ill configured path. It may be different issues for different architectures but given how they all center around the exact same error msg suggests it's a bug with configuring paths. Why using TmpDir works for some and not others is strange. Possibly it resolves the path somewhere in the code so that the dlls can be found.

  23. kommander commented on Dec 20, 2025

    @kommander
    Contributor

    Improvements for windows have been made in the latest versions, did that get better? The tmpdir access issue is a bun issue. You can use BUN_TMPDIR as a workaround.

  24. Universal-Invariant commented on Dec 20, 2025

    @Universal-Invariant

    Improvements for windows have been made in the latest versions, did that get better? The tmpdir access issue is a bun issue. You can use BUN_TMPDIR as a workaround.

    Its seems very different. This time I get a windows installer for opencode and when I installed it I then get a gui window for it rather than it being in the console. I guess that means it is working? I guess that was the TUI change? If so then it seems to be working as expected now. I didn't do anything with the BUN_TMPDIR.

  25. ChazenLi commented on Mar 6, 2026

    @ChazenLi

    I know this issue was originally reported on macOS, but I wanted to add a Windows-specific diagnostic and fix for the same symptom family:

    Failed to initialize OpenTUI render library: Failed to open library

    In my case, the visible symptom looked very similar to this issue, but the actual root cause was more specific:

    • opencode serve --port <port> --hostname 127.0.0.1 worked normally.
    • Plain opencode did not enter the TUI.(Error code 225 indicates Windows Defender rejection)
    • Debug logs showed that the failure happened while loading the temporary OpenTUI render DLL.
    • The critical line was:
    Failed to initialize OpenTUI render library:
    Failed to open library "...Temp\....dll": error code 225 rejection
    
    

    So for my machine, this was not:

    • A database migration problem
    • A provider/API configuration problem
    • An npm or pip cache problem
    • A backend server problem

    It was specifically a Windows security / Defender rejection of the temporary DLL extracted for the TUI renderer.


    How I Isolated It

    The key step was separating backend health from TUI startup.

    I first ran:

    opencode serve --port 36735 --hostname 127.0.0.1
    

    That started successfully and listened on the expected address, which told me the backend was healthy.

    Then I ran plain opencode with debug logs:

    opencode --print-logs --log-level DEBUG
    

    This consistently failed during OpenTUI initialization, not during backend startup.

    That distinction mattered a lot: if serve works but opencode fails during renderer init, the problem is likely in the TUI render library loading path, not in the server/runtime as a whole.


    What did NOT fix it

    These actions did not solve the problem for me:

    • Reinstalling opencode
    • Clearing npm cache
    • Clearing pip cache
    • Changing working directory
    • Only changing the TEMP / TMP directory

    Changing TEMP / TMP by itself did move the extracted DLL to another drive, but Windows still rejected loading it.


    What DID fix it

    The complete fix required creating a dedicated temp directory, pointing the environment variables there, and adding a Windows Defender exclusion. Here are the exact steps:

    Step 1: Create a dedicated temp directory

    New-Item -ItemType Directory -Force -Path F:\OpenCodeTemp | Out-Null
    

    Step 2: Set TEMP and TMP for the current session (Test First)

    $env:TEMP = "F:\OpenCodeTemp"
    $env:TMP  = "F:\OpenCodeTemp"
    

    Then test:

    opencode --print-logs --log-level DEBUG
    

    Note: In my case, the error still happened here, but the log now pointed to a DLL under F:\OpenCodeTemp\...dll, which confirmed that the issue was not the original %LOCALAPPDATA%\Temp path itself.

    Step 3: Make TEMP / TMP permanent for the user

    [Environment]::SetEnvironmentVariable("TEMP", "F:\OpenCodeTemp", "User")
    [Environment]::SetEnvironmentVariable("TMP",  "F:\OpenCodeTemp", "User")
    

    After opening a new PowerShell session, I verified:

    Write-Host "TEMP=$env:TEMP"
    Write-Host "TMP=$env:TMP"
    

    (On my machine this later displayed the Windows short path form, e.g., F:\OPENCO~1, which is completely normal).

    Step 4: Add a Defender exclusion for that directory

    This was the step that actually fixed it. In an elevated (Administrator) PowerShell:

    Add-MpPreference -ExclusionPath "F:\OpenCodeTemp"
    

    You can verify it with:

    Get-MpPreference | Select-Object -ExpandProperty ExclusionPath
    

    Step 5: Restart terminal and launch again

    After reopening PowerShell:

    opencode
    

    At that point, the TUI started normally.


    Practical Conclusion

    If someone hits this issue on Windows and sees the generic OpenTUI failure message, I would strongly recommend checking whether it is actually this more specific variant:

    1. opencode serve ... works.
    2. Plain opencode fails.
    3. Debug logs mention the temporary OpenTUI DLL.
    4. Especially if logs show error code 225 rejection.

    If that pattern matches, the problem is likely Windows Defender blocking the extracted OpenTUI render DLL, and the workaround above should help.


  26. snajjar commented on Mar 12, 2026

    @snajjar

    Same issue here on linux. It worked before, didn't change anything, but now opencode serve or opencode run works. opencode doesn't work anymore (endless start).

    Workaround:
    Investigation shows that deleting /tmp/*.so and then LD_BIND_NOW=1 opencode fixes the issue, if it helps someone here 👍

    It seems that opencode extract opentui lib in tmpfs and never clean up. I didn't check yet, but seeing the number, it seems to be doing that for every subagent launched. At some point, tmpfs is full and opencode doesn't work anymore.
    Forcing the linker to solve all references at starts seems to do the trick.

  27. disarticulate commented on Apr 27, 2026

    @disarticulate

    I had to clear /tmp; it overfillth. Would be nice to have a sanity check.

  28. FireCulex commented on Jul 6, 2026

    @FireCulex

    I was confused by this error myself

    
    mkdir -p ~/.cache/opencode-tmp
    TMPDIR=~/.cache/opencode-tmp opencode
    
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 workingopentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions