Repository navigation
Description
Description
opencode serve is documented as a headless server, but on Linux it still extracts a bundled native OpenTUI shared library (libopentui.so) into /tmp during startup.
In long-running environments where opencode serve is restarted periodically, this causes repeated creation of hidden temp artifacts such as:
/tmp/.58afeffabbf7dede-00000000.so/tmp/.58afffdf9b3fffef-00000000.so
Observed properties:
- each file is about 4.2 MB
- filenames are randomized
- file content is identical across runs
- ELF
SONAMEislibopentui.so - the file is mapped directly by the
opencode serveprocess itself - the artifact is created at startup time, before
pyright-langserverstarts
This means the issue is not primarily about language-server activity. It appears to come from the standalone opencode binary extracting a bundled native library even for serve.
Why this is a problem
For headless server deployments, this behavior is surprising and operationally expensive:
/tmpaccumulates many hidden.sofiles over time- repeated restarts create new copies with different names
- cleanup is hard to automate safely in shared
/tmp - the behavior is especially awkward for long-running service environments, where
serveis used without any terminal UI
What I verified
On Linux, I verified that:
opencode servestarts first- the temp
.soappears immediately after startup pyright-langserverstarts much laterlsofand/proc/<pid>/mapsshow the.sois mapped by theopencode serveprocess- the extracted file reports
SONAME: libopentui.so
Expected behavior
At least one of the following would be preferable:
opencode serveshould avoid loading or extracting OpenTUI native libraries entirely when running in headless mode- the extracted native library should be cleaned up automatically on normal shutdown
- extracted files should be reused from a stable cache path instead of creating a new randomized temp file on each start
- documentation for
serveshould explicitly call out theBUN_TMPDIRrequirement/workaround for service deployments
Suggested improvements
Preferred
- split headless/server builds from TUI-capable builds, so
opencode servedoes not carry OpenTUI runtime baggage at all
Acceptable
- reuse a deterministic cache location for bundled native libs
- unlink temp artifacts after successful load when possible
- provide an explicit server/runtime flag or documented environment variable strategy for temp extraction
Workaround
BUN_TMPDIR helps redirect the extraction location, but it does not solve the underlying accumulation behavior.
Example:
BUN_TMPDIR=/var/lib/opencode-bun-tmp opencode serve --hostname 127.0.0.1 --port 34876This is useful operationally, but it still feels like a workaround rather than the correct headless-server behavior.
Version
Observed on the latest release at the time of filing: v1.3.7
Environment
- OS: Linux
- mode:
opencode serve - deployment style: long-running headless service
Activity
fix: prevent libopentui.so extraction to /tmp on serve/headless mode
github-actions commentedon Jul 3, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
thdxr commentedon Aug 19, 2026
Update: the unbounded native-library temp-file growth described here is fixed in OpenCode V2.
As of V2 build
0.0.0-dev-17643, the compiled CLI uses Bun 1.4.0-canary.1 (681a49bee). That runtime includes oven-sh/bun#29587, which replaces the unique temporary.so/.dylib/.nodeextraction on every load with a deterministic, content-hashed path reused across calls, Workers, processes, and restarts. The V2 build provenance is workflow run 32216069554.This bounds extraction to one reusable file per embedded native module and user instead of allowing unbounded disk growth. It does not mean the temp directory will contain zero native files, and upgrading does not remove files leaked by older builds; those stale randomly named files can be cleaned up after all older OpenCode processes have stopped.