Skip to content

fix: pass caller's PATH to overlay subprocesses - #36

Closed
i-kozlov wants to merge 1 commit into
umputun:masterfrom
i-kozlov:fix/overlay-path-inheritance
Closed

i-kozlov wants to merge 1 commit into
umputun:masterfrom
i-kozlov:fix/overlay-path-inheritance

Conversation

@i-kozlov

@i-kozlov i-kozlov commented Apr 6, 2026

Copy link
Copy Markdown

Problem

On macOS with Homebrew on Apple Silicon, launch-revdiff.sh overlay subprocesses fail to find tools like git-lfs. The overlay is started via sh -c "$CMD", which gets a minimal PATH without /opt/homebrew/bin. This causes git diff to fail inside the revdiff TUI:

error loading files: get changed files: git diff --no-color ...
fatal: the remote end hung up unexpectedly

The script itself runs in the user's shell with the full PATH, but the overlay subprocess (kitty launch, tmux display-popup, wezterm split-pane) spawns a fresh sh that doesn't inherit it.

Fix

Capture the caller's PATH once and pass it explicitly into each overlay using the terminal's native env mechanism:

  • tmux: display-popup -e "PATH=$CALLER_PATH"
  • kitty: launch --env "PATH=$CALLER_PATH"
  • wezterm: env "PATH=$CALLER_PATH" sh -c ... (no native --env flag)

This is shell-agnostic (no dependency on zsh/bash/fish), has zero overhead, and fixes the actual problem without login-shell rehydration or hardcoded paths.

Test plan

  • Tested on macOS Sequoia (Apple Silicon) with kitty overlay — git-lfs found, revdiff TUI loads files correctly
  • tmux: needs verification (same pattern, native -e flag)
  • wezterm: needs verification (uses env wrapper)

On macOS with Homebrew (Apple Silicon), overlay subprocesses started via
`sh -c` get a minimal PATH without /opt/homebrew/bin. This causes tools
like git-lfs to not be found, breaking `git diff` inside revdiff TUI.

Fix: capture the caller's PATH and pass it explicitly using each
terminal's native env mechanism:
- tmux: display-popup -e "PATH=..."
- kitty: launch --env "PATH=..."
- wezterm: env "PATH=..." sh -c (no native --env flag)
@i-kozlov
i-kozlov requested a review from umputun as a code owner April 6, 2026 11:03

@umputun umputun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't reproduce this on the same setup (macOS + Homebrew + Apple Silicon), and nobody else has reported it. the script already resolves revdiff to an absolute path (line 10), so the binary itself is always found. the issue you describe would only affect tools called internally by git (like git-lfs).

that said, the fix is harmless (no-op when PATH is already inherited) and the approach is correct for each terminal. couple things:

  1. the script now also has Ghostty, iTerm2, and Emacs vterm sections that use #!/bin/sh launcher scripts with the same potential issue. if you're fixing PATH inheritance, pls cover those too (add export PATH="$CALLER_PATH" at the top of each launcher script heredoc)
  2. only tested on kitty per the test plan. I'd like to see at least tmux verified since that's the most common case and -e flag behavior varies by tmux version

@i-kozlov

i-kozlov commented Apr 8, 2026

Copy link
Copy Markdown
Author

definitely this only affects tools called internally by git.
actually it does affect only 1 of my repos.
so if no other users affected so far i think it is not actual.

@i-kozlov i-kozlov closed this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants