Skip to content

can not start opencode on ubuntu /tmp does not allow execution of .so #5175

Closed

Description

@falko-apheris

Description

When trying to run opencode it tries to execute/use a shared object file from the /tmp directory, however execution of shared object files on Ubuntu is blocked for security reasons.

> TMPDIR=~/.opencode/tmp opencode --print-logs --log-level DEBUG                                                                                                                               <region:eu-central-1>
INFO  2025-12-06T20:19:48 +153ms service=default version=1.0.134 args=["--print-logs","--log-level","DEBUG"] opencode
ERROR 2025-12-06T20:19:48 +362ms service=acp-command promise={} reason=Failed to initialize OpenTUI render library: Failed to open library "/tmp/.1b7ffdebf6a76fe6-00000001.so": /tmp/.1b7ffdebf6a76fe6-00000001.so: failed to map segment from shared object Unhandled rejection
ERROR 2025-12-06T20:19:48 +0ms service=default e=Failed to initialize OpenTUI render library: Failed to open library "/tmp/.1b7ffdebf6a76fe6-00000001.so": /tmp/.1b7ffdebf6a76fe6-00000001.so: failed to map segment from shared object rejection
ERROR 2025-12-06T20:19:48 +0ms service=default Error: Failed to initialize OpenTUI render library: Failed to open library "/tmp/.1b7ffdebf6a76fe6-00000001.so": /tmp/.1b7ffdebf6a76fe6-00000001.so: failed to map segment from shared object

it would be nice if the tmp directory could be specified or a common directory like ~/.local/share/opencode could be used on systems with standard security hardening.

OpenCode version

1.0.134

Steps to reproduce

sudo snap install bun-js
bun install -g opencode-ai
TMPDIR=~/.opencode/tmp opencode --print-logs --log-level DEBUG 

Operating System

> cat /etc/issue                                                                                                                                                                               Ubuntu 24.04.3 LTS \n \l

Terminal

kitty

Activity

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

    @github-actions
    Contributor

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

    This is a feature request to allow write access to /tmp or specify a custom TMPDIR, which would address the security hardening issue you're experiencing on Ubuntu. Feel free to ignore if your specific case requires a different solution.

  3. falko-apheris commented on Dec 6, 2025

    @falko-apheris
    Author

    follwing the link of the actions box, I found a fix

    BUN_TMPDIR=~/.opencode/tmp opencode --print-logs --log-level DEBUG    
    

    I would still wish that opencode would work out of the box

  4. kommander commented on Dec 20, 2025

    @kommander
    Contributor

    It is a bun issue that is being worked on.

  5. jpcaparas commented on Jan 14, 2026

    @jpcaparas

    For *nix users having this issue, here's a drop-in wrapper command based on this answer:

    opencode() {
        local tmpdir="$HOME/.opencode/tmp"
        mkdir -p "$tmpdir"
        BUN_TMPDIR="$tmpdir" command opencode "$@"
    }
  6. thdxr commented on Mar 25, 2026

    @thdxr
    Member

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

  7. nkedel commented on May 11, 2026

    @nkedel

    Issue is not just Ubuntu:

    Add me to the bunch of users who are hitting this issue; I've worked around it, but here's gemini helping me describe what I hit:

    Title: [Bug] Indefinite hang on startup when /tmp is mounted noexec (WSL/Hardened Linux)
    Description:
    On systems where /tmp is mounted with the noexec flag (common in WSL and hardened Linux environments), opencode hangs indefinitely during the initialization of the OpenTUI render library.
    Behavior Analysis:
    Tracing the process via strace shows that the main process and its child enter an infinite loop of thread synchronization attempts (a "futex storm"). The logs confirm that OpenTUI fails to map its native library from /tmp because of the noexec restriction:

    ERROR service=default e=Failed to initialize OpenTUI render library:
    Failed to open library "/tmp/.7bef6dbfdf7f5fbd-00000001.so":
    failed to map segment from shared object rejection

    Instead of exiting with a fatal error, the process blocks indefinitely on an epoll_pwait2 call, waiting for an event from a native worker that never successfully initialized.
    Steps to Reproduce:

    1. Mount /tmp with noexec (e.g., sudo mount -o remount,noexec /tmp).
    2. Run opencode.
    3. The process will hang silently with high CPU usage or indefinite blocking.

    Workaround:
    Directing temporary file extraction to a location with execution permissions resolves the issue:
    export TMPDIR=~/tmp && opencode
    Technical Environment:

    • OS: WSL / Gentoo (defaults)
    • Node Version: v24.15.0 (LTS)
    • Opencode Version: 1.14.48

    Suggested Fix:

    • The application should detect if library mapping fails and exit with a clear error message.
    • Ideally, OpenTUI should respect TMPDIR consistently or use a more standard, non-temporary path for its native binary components.
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