Skip to content

OpenCode plugin: no rewrite when rtk is not on OpenCode's PATH (Desktop launched from the macOS GUI) #4462

Closed

Description

@KuSh

When OpenCode is started from a launcher whose PATH lacks the directory rtk is installed in (the macOS Dock with rtk in ~/.cargo/bin or /opt/homebrew/bin, for example), the OpenCode plugin finds no rtk and every command runs unrewritten. #2039 reported this and was closed into #3326; #4187 closes #3326 for the Desktop $ and Windows which failures, so this issue keeps the PATH case.

Measured while reviewing #4187, on OpenCode 1.18.10 and 2.0.22:

  • OpenCode's bash/shell tool runs commands with OpenCode's own PATH. It does not source .profile, .bashrc or .bash_profile; all three were tried with the directory exported.
  • So locating rtk somewhere else (RTK_BIN, ~/.cargo/bin, Homebrew) is not enough on its own: rtk hook opencode answers a bare rtk …, and the tool then fails with rtk: command not found.

A fix has to make the rewritten command resolve to the binary the plugin found. Two shapes to evaluate (neither tried yet): add that directory to the spawned shell's PATH (V1 shell.env, V2 ctx.shell.hook("create.before")), or have the rewrite carry the resolved path.

Rows a fix has to pass:

  • rtk only in ~/.cargo/bin, not on OpenCode's PATH → ls -la is rewritten and runs.
  • rtk only at RTK_BIN → same.
  • rtk on PATH → unchanged behaviour.

Activity

  1. rtk-wshm-sync-bot commented on Oct 5, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 86%

    Summary

    OpenCode plugin doesn't rewrite commands when rtk isn't on OpenCode's own PATH (e.g. Dock-launched Desktop), since the spawned shell doesn't inherit shell profile PATH additions.

    📁 Relevant files
    • plugin/opencode.ts
    • src/hook/opencode.rs

    Suggested Actions

    1. Decide between injecting resolved dir into shell.env/create.before hook vs. emitting the resolved absolute rtk path in …
    2. Validate against the three PATH scenarios listed (~/.cargo/bin only, RTK_BIN only, on PATH)
    3. Cross-reference feat(hook/opencode): support OpenCode V2, Desktop, and Windows (#3463, #3326) #4187 and rtk init --opencode plugin silently does nothing on Desktop ($ is not a function) and on Windows (which not found) #3326 for how the Desktop $/Windows which cases were resolved
    4. Check OpenCode permission rules: rtk's config loader diverges from OpenCode's config resolution #4422 (OpenCode config loader) since both touch OpenCode plugin internals

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  2. added a commit that references this issue on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions