2026-05-31 Repository implementation Issue gh-forgejo-shim-2je

Made the generated gh shim independent of PATH

The wrapper now invokes the installed package through the pipx venv Python executable, so GUI apps do not need gh-forgejo-shim itself to be discoverable through PATH.

Summary

Fixed the failure mode behind Codex.app reporting GitHub CLI unavailable. The generated ~/.local/bin/gh wrapper previously ran exec gh-forgejo-shim gh "$@", which fails in stripped GUI environments where gh-forgejo-shim is not on PATH. It now executes python -m gh_forgejo_shim gh "$@" through an absolute interpreter path captured at install time.

Changes Made

Shim generation

Updated shim_script to emit an absolute Python module invocation using the interpreter running gh-forgejo-shim install-shim.

Compatibility

Kept old generated wrappers recognizable as managed so uninstall and overwrite behavior remain safe.

Tests

Added tests for absolute module invocation and for recognizing the older managed shell wrapper.

Context

Running the current wrapper with a stripped PATH reproduced the GUI app failure: exec: gh-forgejo-shim: not found. Codex.app can find gh, but once the wrapper starts, it must be able to run the package without depending on another PATH lookup.

Important Implementation Details

Relevant Diff Snippets

The snippet below uses the Diffs FileDiff component when available, with a static fallback. Reference: Diffs documentation.

Generated wrapper command

def shim_script(python_executable: str | None = None) -> str:
    executable = python_executable or sys.executable
    return "\n".join(
        [
            "#!/bin/sh",
            f"# {MARKER}",
            f'exec {shlex.quote(executable)} -m gh_forgejo_shim gh "$@"',
            "",
        ]
    )

Expected Impact for End-Users

Codex.app and other GUI tools can run the shim even when their subprocess environment does not expose the pipx app directory in PATH. Normal terminal use is unchanged.

Validation

Issues, Limitations, and Mitigations

Follow-up Work

No new follow-up Beads issues were needed for this focused compatibility fix.