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
OpenCode Desktop does not detect rtk when launched from macOS GUI #2039
RTK works when OpenCode is started from a terminal, but it does not work when using OpenCode Desktop launched normally.
This suggests the OpenCode Desktop runtime may not be loading the same environment as the user’s shell session. As a result, the RTK OpenCode plugin may fail to detect or execute the rtk binary even though RTK is installed and available in the terminal.
Expected Behavior
OpenCode Desktop should load the RTK plugin.
Actual Behavior
Starting OpenCode from terminal: RTK works.
Starting OpenCode Desktop normally: RTK does not appear to run.
Possible Cause
The Desktop app may be running with a different environment than the user’s login shell, especially a different PATH. The RTK plugin currently depends on resolving rtk from the runtime environment, so it may disable itself if the binary is not discoverable there.
Reproduction
Install and configure RTK for OpenCode.
Confirm RTK works when OpenCode is launched from terminal.
Launch OpenCode Desktop normally.
Run a command that should be rewritten by RTK.
Observe that RTK is not used.
Reacted by Damián, Mahmudin muttaqin, Leonardo Lessa, Valentin Perignon, BEREMIZ RENO CAVALCANTI RODRIGUES DE MACÊDO, amnesia and Yann G
Here is the plugin modification I mentioned that I made so that it would work on my Mac.
importtype{Plugin}from"@opencode-ai/plugin"import{existsSync}from"fs"import{spawn}from"child_process"// RTK OpenCode plugin — rewrites commands to use rtk for token savings.// Requires: rtk >= 0.23.0 installed at a known path.//// This is a thin delegating plugin: all rewrite logic lives in `rtk rewrite`,// which is the single source of truth (src/discover/registry.rs).// To add or change rewrite rules, edit the Rust registry — not this file.constRTK_CANDIDATES=["/opt/homebrew/bin/rtk","/usr/local/bin/rtk",(process.env.HOME??"")+"/.local/bin/rtk",]functionfindRtk(): string|null{for(constcandidateofRTK_CANDIDATES){if(existsSync(candidate))returncandidate}returnnull}functionrtkRewrite(bin: string,command: string): Promise<string>{returnnewPromise((resolve)=>{constproc=spawn(bin,["rewrite",command])letout=""proc.stdout.on("data",(d)=>{out+=d})proc.on("close",()=>resolve(out.trim()))proc.on("error",()=>resolve(""))})}exportconstRtkOpenCodePlugin: Plugin=async()=>{constrtkBin=findRtk()if(!rtkBin){console.warn("[rtk] rtk binary not found — plugin disabled")return{}}return{"tool.execute.before": async(input,output)=>{consttool=String(input?.tool??"").toLowerCase()if(tool!=="bash"&&tool!=="shell")returnconstargs=output?.argsif(!args||typeofargs!=="object")returnconstcommand=(argsasRecord<string,unknown>).commandif(typeofcommand!=="string"||!command)returnconstrewritten=awaitrtkRewrite(rtkBin,command)if(rewritten&&rewritten!==command){;(argsasRecord<string,unknown>).command=rewritten}},}}
Here's the quick win I found :
$ (shell Bun) is not available in tool.execute.before, nor for detecting the binary at startu. Replaced by the native existsSync and spawn.
execFile rejected exit code 3 from rtk rewrite as an error — replaced by spawn, which ignores the exit code.
Reacted by Marvin Kruse, Jérémie G. and Steven Watremez
Closing as a duplicate of #3326. The linked fix work (#2153) showed that OpenCode Desktop runs the plugin under Node, where the Bun $ helper is missing, and the plugin reports that as 'not found in PATH'. #3326 tracks that same failure, plus the Windows which case, and has the open fixes linked. Please follow up there, especially if your Desktop setup still fails once $ is replaced.
Activity
pszymkowiak commentedon May 27, 2026
🔍 Automated Triage
bugmediumSummary
OpenCode Desktop on macOS doesn't inherit shell PATH, causing RTK binary detection to fail; needs GUI app PATH resolution fix.
Triaged automatically by wshm · This is an automated analysis, not a human review.
alexandre-leites commentedon Jun 2, 2026
Any workaround while this is not merged?
ishrakr commentedon Jun 11, 2026
bump. Looking for workarounds for this as well.
foch01 commentedon Jun 22, 2026
Here is the plugin modification I mentioned that I made so that it would work on my Mac.
Here's the quick win I found :
$(shell Bun) is not available intool.execute.before, nor for detecting the binary at startu. Replaced by the nativeexistsSyncandspawn.execFilerejectedexit code 3fromrtk rewriteas an error — replaced byspawn, which ignores the exit code.pkorecki commentedon Jun 23, 2026
Hello, is this defect to be fixed in RTK plugin or more in OpenCode Desktop app?
trongnsiwa commentedon Jun 26, 2026
I have same issue
nusbru commentedon Aug 13, 2026
Same issue using linux OpenCode Desktop application.
KuSh commentedon Sep 26, 2026
Closing as a duplicate of #3326. The linked fix work (#2153) showed that OpenCode Desktop runs the plugin under Node, where the Bun
$helper is missing, and the plugin reports that as 'not found in PATH'. #3326 tracks that same failure, plus the Windowswhichcase, and has the open fixes linked. Please follow up there, especially if your Desktop setup still fails once$is replaced.