Repository navigation
Description
What happened
I run the standalone freebuff binary through an explicit ELF interpreter instead of exec'ing it directly (glibc-runner on Termux/Android, no proot). The CLI starts fine, and the in-process file tools work (read/write/edit), but every tool that spawns a process fails:
Terminal command broker failed: terminal command broker protocol response was missing
Restart Freebuff and try again.
code_search fails the same way:
Failed to execute ripgrep: ENOENT: no such file or directory,
posix_spawn '/data/data/com.termux/files/usr/glibc/lib/rg'.
Vendored ripgrep not found; ensure @codebuff/sdk is up-to-date or set CODEBUFF_RG_PATH.
freebuff doctor passes, because it never exercises the broker.
This is not a request for official Termux support — the bug is generic to any launch that goes through a loader rather than direct execve() of the bundle, which is also how some Nix wrappers and sandboxed launchers work.
Steps to reproduce
Any Linux, with the standalone binary:
# works (direct exec):
~/.config/manicode/freebuff
# starts, but every tool that spawns a command fails:
$PREFIX/glibc/bin/ld.so --library-path $PREFIX/glibc/lib ~/.config/manicode/freebuffThen ask the agent to run any command (e.g. echo ok). File tools keep working; shell/git/code search do not.
Environment: Termux (unrooted), Android 15, aarch64; freebuff 0.2.36 standalone binary (npm launcher output) run through glibc 2.44 from glibc-runner 2.0-3.
Why it fails
When a program is started as ld.so prog, the kernel's main executable is the loader, so /proc/self/exe — and therefore process.execPath — is the loader, not the bundle:
$ $PREFIX/glibc/bin/ld.so --library-path $PREFIX/glibc/lib $PREFIX/glibc/bin/bash -c 'readlink /proc/$$/exe'
/data/data/com.termux/files/usr/glibc/lib/ld-linux-aarch64.so.1
cli/src/utils/terminal-command-broker.ts (defaultBrokerInvocation) spawns the broker with executable: process.execPath. The child that actually runs is therefore:
$ $PREFIX/glibc/bin/ld.so --terminal-command-broker
ld.so: unrecognized option '--terminal-command-broker'
ld.so exits immediately without writing the protocol file. Because the exec itself succeeds (it is the loader that fails), no spawn error is emitted; the parent only sees the missing result file and reports protocol response was missing.
cli/src/native/ripgrep.ts makes the same assumption: in compiled mode it extracts/looks for rg in path.dirname(process.execPath), i.e. $PREFIX/glibc/lib/rg, which does not exist — hence the posix_spawn .../glibc/lib/rg ENOENT. packages/code-map/src/init-node.ts and cli/src/pre-init/tree-sitter-wasm.ts also derive asset locations from dirname(process.execPath).
Suggested fix
- Preferred: run the broker in-process (or as a worker) instead of re-exec'ing the bundle.
- If a separate process is required, resolve the bundle path independently of
process.execPath— e.g.process.argv[0]/process.argv0when it points at the bundle, or detect a loader (ld-linux*,ld.so*) and re-exec through it:[execPath, '--library-path', dirname(execPath), bundlePath, TERMINAL_COMMAND_BROKER_FLAG]. - Or expose an override for the broker command, mirroring
CODEBUFF_RG_PATH, so launchers that exec via a loader can supply the correct command line. - Apply the same resolution to the
dirname(process.execPath)lookups forrgandtree-sitter.wasm.
Workaround
CODEBUFF_RG_PATH=~/.config/manicode/rg fixes code search only. Nothing I can set in this environment fixes the broker, because its executable path comes from process.execPath; the CLI has to be launched through proot instead, which defeats the point of running it natively.
Logs
Terminal tool result as surfaced in the session:
Terminal command broker failed: terminal command broker protocol response was missing
Restart Freebuff and try again.
Repeating the call produces the same result; restarting Freebuff does not change it.
Activity
MBanucu commentedon Nov 18, 2026
FWIW, I kept the repro and the workaround in a small project: https://github.com/MBanucu/freebuff-native-termux
The relevant piece for this issue is
shim/freebuff-spawn-shim.c, a freestandingLD_PRELOADobject that rewrites exactly one exec —path == process.execPath(the loader) plus--terminal-command-broker— intold.so --library-path DIR BINARY --terminal-command-broker. With it the protocol file comes back as{"ok":true,"exitCode":0};code_searchis fixed separately withCODEBUFF_RG_PATH, as you suggested.test/shim-test.shasserts the rewritten argv and that children don't inherit the preload, so it can serve as a spec for a real fix.Not proposing the preload hook as the fix — it just confirms the failure is confined to how the broker resolves its executable. Happy to test a patch that resolves the bundle independently of
process.execPath.MBanucu commentedon Nov 18, 2026
For anyone hitting this on Termux: the cause is exactly what the title says. When the binary is started through the glibc loader (
ld-linux-aarch64.so.1 --library-path … freebuff),process.execPathis the loader, so the broker re-exec sends--terminal-command-brokerto the loader, which rejects it before it can write its result file. The samedirname(process.execPath)assumption is what breaks the ripgrep extraction.I have a workaround working on aarch64 against 0.2.36, on a stock Termux userland (no proot, no ptrace, no second userland): a small
LD_PRELOADshim that rewrites that one exec intoand strips
LD_PRELOADfrom child environments so bionicsh/git/rgstart normally. The freebuff binary is used untouched.This is a workaround, not a fix. The real fix is probably one of:
execPathis a loader and re-exec<loader> --library-path … <entry> --terminal-command-broker, orprocess.execPath, orprocess.argv[1]whenexecPathresolves to a dynamic loader.I'm not asking you to host or adopt the shim. If someone wants to iterate on a real fix, I'm happy to test patches against 0.2.36 on the device and report back.
Fix process.execPath resolution when launched via an ELF loader