Skip to content

Prepend Homebrew prefixes to $PATH in vimrc for Finder/Dock launches#207

Draft
ikuwow wants to merge 1 commit into
mainfrom
fix/vimrc-finder-launch-path-73
Draft

Prepend Homebrew prefixes to $PATH in vimrc for Finder/Dock launches#207
ikuwow wants to merge 1 commit into
mainfrom
fix/vimrc-finder-launch-path-73

Conversation

@ikuwow

@ikuwow ikuwow commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Closes #73.

Why

Neovide launched from Finder/Dock starts via /usr/bin/login -fpq which does not source the login shell init files, so $PATH stays at the bare /usr/bin:/bin:/usr/sbin:/sbin. The vimrc's existing executable('brew') check then fails and emits a warning every launch, plus every brew-installed tool referenced later in the rc is silently unavailable.

The issue's own suggestion ("vimrcの冒頭でPATHを補完する対策") is the simplest fix and keeps the workaround on the dotfiles side rather than depending on a future upstream Neovide change (neovide/neovide#3243). The existing config.toml neovim-bin absolute path fix (#72) is preserved — this PR fixes the PATH inside the running vim.

What

Adds a short macOS-only block right after set nocompatible that prepends /opt/homebrew/bin (Apple Silicon) and /usr/local/bin (Intel) to $PATH when present and not already on it. Idempotent (the $PATH !~# '\V' . s:brew_path guard avoids double-prepending when the login shell already set it up).

Notes

  • The block runs before the rest of the rc, so the downstream executable('brew') / g:python3_host_prog / g:copilot_node_command logic sees the populated PATH.
  • macOS-only via has('mac') || has('macunix') — Linux launches do not hit this code path.

Verification

  • Headless vim test simulating Finder PATH: env -i PATH=/usr/bin:/bin:/usr/sbin:/sbin vim -u xdg-config/vim/vimrc -es '+redir>...' '+echo $PATH' '+qall' prints /usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin. Both brew prefixes are prepended, original PATH preserved on the right.
  • Launch Neovide.app from Finder. Inside neovim run :echo $PATH and confirm /opt/homebrew/bin is present. (GUI launch only available on the desktop session, deferred.)
  • :!brew --prefix returns /opt/homebrew instead of "command not found" inside Neovide.
  • No "brew not found" warning at startup inside Neovide.
  • Idempotent: when $PATH already contains /opt/homebrew/bin (terminal-launched vim), the !~# guard skips the prepend; confirmed by code reading (the loop only modifies $PATH inside the if isdirectory(...) && $PATH !~# '\V' . s:brew_path branch).

When Neovide.app (or any vim launched from Finder/Dock on macOS) starts,
the login shell init files are not sourced and $PATH stays at the bare
/usr/bin:/bin:/usr/sbin:/sbin. brew and the rest of the brew-installed
toolchain are then invisible, executable("brew") returns 0, and the
existing warning fires every launch.

Prepends the well-known brew prefixes (/opt/homebrew/bin for Apple
Silicon, /usr/local/bin for Intel) when present and not already on
$PATH, guarded to macOS only.

Closes #73.

Co-authored-by: Claude Opus 4.6 <[email protected]>
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.

Neovide launched from Finder/Dock does not inherit PATH

1 participant