Skip to content

Replace __fish_reconstruct_path hook on first run of __shadowenv_hook to avoid incorrect reordering of PATH#166

Merged
lilyinstarlight merged 1 commit into
mainfrom
fix-fish-path
Apr 28, 2026
Merged

Replace __fish_reconstruct_path hook on first run of __shadowenv_hook to avoid incorrect reordering of PATH#166
lilyinstarlight merged 1 commit into
mainfrom
fix-fish-path

Conversation

@lilyinstarlight
Copy link
Copy Markdown
Contributor

@lilyinstarlight lilyinstarlight commented Apr 23, 2026

PATH entries set via $fish_user_paths get reordered first in $PATH in
fish shell via the __fish_reconstruct_path hook, even if they were added before manually changing $PATH

If we are updating $PATH, we need to replace the __fish_reconstruct_path hook during the first run of __shadowenv_hook (to reduce initial shell startup unexpected behavior for other hooks) such that the __fish_reconstruct_path hook no longer hoists existing $fish_user_paths entries to the front of PATH every change, before we can change $PATH via set -gx PATH

Otherwise the existing contents of the $fish_user_paths variable (set by other hooks) will get erroneously reordered in front of expected shadowenv entries in new shells (including subprocesses started by our tooling in the same shell session)

@lilyinstarlight lilyinstarlight requested a review from burke as a code owner April 23, 2026 13:56
@lilyinstarlight lilyinstarlight marked this pull request as draft April 23, 2026 14:28
@lilyinstarlight lilyinstarlight changed the title Set fish PATH via fish_user_paths to avoid incorrect reordering via __fish_reconstruct_path hook Replace __fish_reconstruct_path hook on first run of __shadowenv_hook to avoid incorrect reordering of PATH Apr 23, 2026
@lilyinstarlight lilyinstarlight marked this pull request as ready for review April 23, 2026 21:02
Comment thread sh/shadowenv.fish.in Outdated
@lilyinstarlight lilyinstarlight merged commit 1127b36 into main Apr 28, 2026
9 checks passed
@lilyinstarlight lilyinstarlight deleted the fix-fish-path branch April 28, 2026 16:50
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.

3 participants