opencode icon indicating copy to clipboard operation
opencode copied to clipboard

OpenCode TUI Hangs on Fedora Linux (npm & bun & standalone)

Open nilltadios opened this issue 11 months ago • 8 comments

Description

The interactive Terminal User Interface (TUI) of opencode freezes immediately upon startup on Fedora Linux. This occurs with both the bun installation and the standalone binary.

The process hangs on a futex lock, requiring a SIGTERM to exit. However, non-interactive commands (opencode run, opencode stats) and opencode serve work correctly.

System Information

  • OS: Fedora Linux (kernel 6.x)
  • CPU: AMD Ryzen 7 7735HS
  • Terminal: xterm / gnome-terminal
  • OpenCode Version: 1.0.193

Logs / Trace

Running strace opencode shows the process hanging on futex calls:

futex(0x..., FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, ...)
sched_yield()
...

Workarounds

  • Use opencode run "query" for single commands.
  • Use opencode serve and connect via the Web UI.
  • opencode attach also fails (likely uses the same TUI code).

Request

Please investigate the TUI rendering or threading logic for compatibility with Fedora/Red Hat systems, particularly on AMD hardware if relevant.

OpenCode version

1.0.193

Steps to reproduce

  1. Install opencode via bun (bun install -g opencode-ai) OR via the standalone script.
  2. Run opencode (interactive mode) in the terminal.
  3. The application displays nothing or hangs immediately.
  4. The process cannot be interrupted easily (sometimes requires kill).

Screenshot and/or share link

Image

Operating System

Fedora 43

Terminal

Cosmic Terminal, and GNOME Terminal

nilltadios avatar Dec 24 '25 03:12 nilltadios

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

  • #5361: TUI freezes for ~10 seconds periodically on WSL2 (regression in v1.0.129) - Similar TUI hang/freeze behavior with opentui, though on different OS
  • #6057: Nothing is displayed - Black screen issue on Windows Terminal with OpenCode v1.0.193
  • #4140: black screen when using >1.0.46 - Black screen on startup on macOS with opentui

These issues all involve TUI rendering or responsiveness problems in v1.0+. Your Fedora Linux hang might be related to the opentui library changes that introduced the WSL2 freezing regression in v1.0.129.

Feel free to ignore if your specific case is distinct from these.

github-actions[bot] avatar Dec 24 '25 03:12 github-actions[bot]

Additional findings and working containerized workaround:

I did some more investigation and found a working workaround using Podman containers. Here are my findings:

Environment

  • Fedora 43, kernel 6.17.12-300.fc43.x86_64
  • AMD Ryzen 7 7735HS
  • Terminals tested: GNOME Terminal, Cosmic Terminal
  • OpenCode 1.0.203

What I tried

Approach Result
Native install (bun, curl script) Hangs on futex
Distrobox with Alpine Still hangs (shares host kernel)
Raw Podman container with Alpine Works

Key finding

The critical difference is PTY allocation, not the libc implementation (glibc vs musl).

  • Distrobox inherits the host's terminal state → still hangs
  • Podman with -it allocates a fresh pseudoterminal → works

This suggests the issue is in how opentui interacts with the terminal, specifically something about the inherited terminal state on Fedora that causes the futex deadlock.

Working workaround

I created a wrapper script that runs opencode in a Podman container:

#!/bin/bash
# /usr/local/bin/opencode
# Workaround for TUI hang issue on Fedora

USERNS_OPT=""
if [ "$(id -u)" -ne 0 ]; then
    USERNS_OPT="--userns=keep-id"
fi

exec podman run -it --rm \
    --name opencode-session \
    $USERNS_OPT \
    --network=host \
    --security-opt label=disable \
    -v "$HOME:$HOME" \
    -w "${PWD}" \
    -e "HOME=$HOME" \
    -e "TERM=${TERM:-xterm-256color}" \
    localhost/opencode "$@"

With a minimal Alpine-based Containerfile:

FROM docker.io/library/alpine:3.21
RUN apk add --no-cache bash curl git nodejs npm python3
RUN curl -fsSL https://opencode.ai/install | bash \
    && mv /root/.opencode/bin/opencode /usr/local/bin/opencode \
    && chmod 755 /usr/local/bin/opencode
WORKDIR /workspace
ENTRYPOINT ["opencode"]

This gives full functionality with home directory access and host networking.

Hypothesis

The issue might be related to terminal capabilities or stty settings that Fedora's terminals set differently. The fresh PTY in the container starts with a clean state, bypassing whatever initialization causes the deadlock.

It might be worth investigating what terminal attributes opentui reads/sets at startup and whether there's a specific tcgetattr/tcsetattr or termios setting that differs between a fresh PTY and Fedora's terminal emulators.

nilltadios avatar Dec 27 '25 11:12 nilltadios

Bug: opencode hangs on systems with noexec /tmp

Environment

  • OS: Fedora 43
  • /tmp mounted with noexec (common on hardened Linux systems following CIS benchmarks)

Problem

opencode hangs indefinitely on systems where /tmp is mounted with the noexec option. The same binary works perfectly in containers (where /tmp typically allows exec).

Root Cause

The Bun runtime extracts native helper modules (.so files) to /tmp and attempts to execute them via mmap with PROT_EXEC. When the kernel blocks this due to noexec, the application hangs silently with no error message.

Current Workaround

Users must remove noexec from /tmp, which is a security trade-off:

# For systemd-managed /tmp
sudo mkdir -p /etc/systemd/system/tmp.mount.d
sudo tee /etc/systemd/system/tmp.mount.d/override.conf << 'EOF'
[Mount]
Options=mode=1777,strictatime,nodev,nosuid
EOF

sudo systemctl daemon-reload
sudo mount -o remount,exec /tmp

Feature Request

Please consider adding an environment variable (e.g., OPENCODE_TMPDIR or respecting BUN_TMPDIR) to allow users to specify an alternative temp directory that permits execution. This would support hardened Linux environments without requiring system-wide security changes.

Many enterprise and security-conscious users run with noexec /tmp as a baseline hardening measure.

nilltadios avatar Dec 28 '25 18:12 nilltadios

Having the same issue, making opencode completely unusable. Would be great if opencode could respect the TMPDIR variable.

kabo avatar Jan 15 '26 09:01 kabo

Update: With version 1.1.53 this command works for me:

TMPDIR=~/.opencode/tmp BUN_TMPDIR=~/.opencode/tmp opencode

kabo avatar Feb 10 '26 06:02 kabo

Having same issue, none of the workaround fixes it for me.

running strace opencode, the last outputs is

epoll_ctl(17, EPOLL_CTL_ADD, 18, {events=EPOLLIN, data=0x12}) = 0
epoll_ctl(17, EPOLL_CTL_ADD, 20, {events=EPOLLIN, data=0x14}) = 0
epoll_pwait(17, 0x7ffd23ebd740, 1024, -1, NULL, 8) = -1 EINTR (Interrupted system call)
--- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---
epoll_pwait(17%

I got opencode to launch with OPENCODE_DISABLE_DEFAULT_PLUGINS=true opencode

if I run just opencode and look for running processes, I see opencode add --force --exact --cwd /home/atinocom/.config/cache/opencode [email protected] so maybe there's some error trying to login

MrMarble avatar Feb 10 '26 09:02 MrMarble

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

github-actions[bot] avatar Apr 12 '26 03:04 github-actions[bot]

Having same issue with (1.4.0), just hangs on Fedora 43 KDE with all latest updates:

ERROR 2026-04-18T18:50:44 +12ms service=default e=Failed to initialize OpenTUI render library: Failed to open library "/tmp/.fea7bcdffff56fe7-00000001.so": /tmp/.fea7bcdffff56fe7-00000001.so: failed to map segment from shared object rejection
ERROR 2026-04-18T18:50:44 +0ms service=default Error: Failed to initialize OpenTUI render library: Failed to open library "/tmp/.fea7bcdffff56fe7-00000001.so": /tmp/.fea7bcdffff56fe7-00000001.so: failed to map segment from shared object
ERROR 2026-04-18T18:50:54 +9957ms service=models.dev error=The operation timed out. Failed to fetch models.dev

kinfo:

Operating System: Fedora Linux 43
KDE Plasma Version: 6.6.4
KDE Frameworks Version: 6.25.0
Qt Version: 6.10.3

installed via Homebrew (brew info opencode):

==> opencode ✔: stable 1.4.0 (bottled)
AI coding agent, built for the terminal
https://opencode.ai
Installed (on request)
/home/linuxbrew/.linuxbrew/Cellar/opencode/1.4.0 (12 files, 167.4MB) *
  Poured from bottle using the formulae.brew.sh API on 2026-04-15 at 17:39:23
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/o/opencode.rb
License: MIT
==> Dependencies
Required (2): node ✔, ripgrep ✔
Recursive Runtime (36): 36 ✔, 0 ✘
==> Analytics
install: 26,084 (30 days), 78,935 (90 days), 181,997 (365 days)
install-on-request: 26,074 (30 days), 78,916 (90 days), 181,972 (365 days)
build-error: 2 (30 days)

and node:

==> node ✔: stable 25.9.0 (bottled), HEAD
Open-source, cross-platform JavaScript runtime environment
https://nodejs.org/
Installed (as dependency)
/home/linuxbrew/.linuxbrew/Cellar/node/25.9.0_2 (1,889 files, 105.2MB) *
  Poured from bottle using the formulae.brew.sh API on 2026-04-15 at 00:44:34
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/n/node.rb
License: MIT
==> Dependencies
Required (19): ada-url ✔, brotli ✔, c-ares ✔, hdrhistogram_c ✔, icu4c@78 ✔, libnghttp2 ✔, libnghttp3 ✔, libngtcp2 ✔, libuv ✔, llhttp ✔, merve ✔, nbytes ✔, openssl@3 ✔, simdjson ✔, sqlite ✔, uvwasi ✔, zstd ✔, zlib-ng-compat ✔, python ✔
Recursive Runtime (33): 33 ✔, 0 ✘
Dependents: 2
==> Options
--HEAD
        Install HEAD version
==> Analytics
install: 337,108 (30 days), 1,016,110 (90 days), 2,938,650 (365 days)
install-on-request: 268,444 (30 days), 799,438 (90 days), 2,401,147 (365 days)
build-error: 1,106 (30 days)

xkuznetc avatar Apr 18 '26 18:04 xkuznetc