You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Failed to initialize OpenTUI render library: Failed to open library. #3765
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.
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.
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.
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.
$ 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
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)
$ 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.
$ 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?
$ 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?
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.
A few cross-platform notes about TMPDIR and mktemp that may be relevant, which I encountered:
Linux /tmp is almost always an ephemeral RAMdisk via being formatted as tmpfs.
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).
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.
A few cross-platform notes about TMPDIR and mktemp that may be relevant, which I encountered:
Linux /tmp is almost always an ephemeral RAMdisk via being formatted as tmpfs.
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).
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.
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.
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.
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:
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.
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:
opencode serve ... works.
Plain opencode fails.
Debug logs mention the temporary OpenTUI DLL.
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.
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.
Activity
github-actions commentedon Nov 2, 2025
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.
guoqiao commentedon Nov 2, 2025
+1, I also get this error after upgrade.
thdxr commentedon Nov 3, 2025
what cpu do you have
guoqiao commentedon Nov 3, 2025
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:
Failed to initialize OpenTUI render libraryerror happened.I have downgraded to
v0.15.31(the last version before v1.0.0) and get it working for now.youngtai commentedon Nov 3, 2025
Same error but thrown in a different place:
Tried installing with the install script and
npm- both same results.Device: M4 Pro MBP
Opencode version:
1.0.18thdxr commentedon Nov 4, 2025
if you have this error on mac does this work
touch $TMPDIR/test.dylibErSoul commentedon Nov 4, 2025
I'm having this same error for windows. Same result from NPM & the bash script with curl; and for git-bash, cmd, and powershell.
devahmedshendy commentedon Nov 4, 2025
@thdxr it is not allowed:
thdxr commentedon Nov 4, 2025
hm wonder why this is the case
thdxr commentedon Nov 4, 2025
TMPDIR=/tmp opencodethis doesn't work either right?
devahmedshendy commentedon Nov 4, 2025
@thdxr no no it works when running
TMPDIR=/tmp opencode, that's it, can it work without issues after that?devahmedshendy commentedon Nov 4, 2025
btw, I didn't run any command in any restricted context, just open normal terminal and use it.
5 remaining items
devahmedshendy commentedon Nov 19, 2025
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.
apdt commentedon Nov 19, 2025
I'm seeing this issue on 1.0.78:
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):Universal-Invariant commentedon Nov 19, 2025
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:
Universal-Invariant commentedon Nov 19, 2025
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
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.
apdt commentedon Nov 19, 2025
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?
Universal-Invariant commentedon Nov 19, 2025
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.
pmarreck commentedon Nov 22, 2025
A few cross-platform notes about
TMPDIRandmktempthat may be relevant, which I encountered:Linux /tmp is almost always an ephemeral RAMdisk via being formatted as
tmpfs.Mac
mktempby 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 whatTMPDIRis set to, unless you specify$TMPDIRas part of the template argument tomktemp, or pass--tmpdirto it (see below).On my Mac, I added a setup that puts
/tmpon a RAMdisk when I log in, so I can enjoy the advantages of not wearing down my SSD, but there's a catch:/tmpis 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:
To convince
mktemp,gmktemp(the GNU version, if you're on Mac and it's installed) to actually USETMPDIR, you can pass--tmpdirto it when you call it.Universal-Invariant commentedon Nov 22, 2025
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.
kommander commentedon Dec 20, 2025
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.
Universal-Invariant commentedon Dec 20, 2025
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.
ChazenLi commentedon Mar 6, 2026
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:
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.1worked normally.opencodedid not enter the TUI.(Error code 225 indicates Windows Defender rejection)So for my machine, this was not:
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:
That started successfully and listened on the expected address, which told me the backend was healthy.
Then I ran plain
opencodewith debug logs:This consistently failed during OpenTUI initialization, not during backend startup.
That distinction mattered a lot: if
serveworks butopencodefails 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:
opencodeTEMP/TMPdirectoryChanging
TEMP/TMPby 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
Step 2: Set TEMP and TMP for the current session (Test First)
Then test:
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%\Temppath itself.Step 3: Make TEMP / TMP permanent for the user
After opening a new PowerShell session, I verified:
(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:
You can verify it with:
Step 5: Restart terminal and launch again
After reopening PowerShell:
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:
opencode serve ...works.opencodefails.If that pattern matches, the problem is likely Windows Defender blocking the extracted OpenTUI render DLL, and the workaround above should help.
snajjar commentedon Mar 12, 2026
Same issue here on linux. It worked before, didn't change anything, but now
opencode serveoropencode runworks.opencodedoesn't work anymore (endless start).Workaround:
Investigation shows that deleting
/tmp/*.soand thenLD_BIND_NOW=1 opencodefixes 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.
disarticulate commentedon Apr 27, 2026
I had to clear /tmp; it overfillth. Would be nice to have a sanity check.
FireCulex commentedon Jul 6, 2026
I was confused by this error myself