Skip to content

fix: stop putting ^/dev/null on PATH in activate.fish - #427

Merged
ekalinin merged 1 commit into
ekalinin:masterfrom
r3wretrhy:fix/fish-path-caret-redirect-400
Oct 3, 2026
Merged

ekalinin merged 1 commit into
ekalinin:masterfrom
r3wretrhy:fix/fish-path-caret-redirect-400

Conversation

@r3wretrhy

@r3wretrhy r3wretrhy commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #400.

activate.fish ended its PATH line with a caret redirect:

set -gx PATH ... $PATH ^/dev/null

fish 3.1+ defaults to stderr-nocaret (stderr-nocaret became the default in 3.1 and read-only in 3.3; fish 3.0 still treated ^ as a redirect by default), so ^ is no longer a stderr redirect. The token lands in PATH as a literal ^/dev/null entry.

Per review: drop the redirect entirely (fish 3.0+ no longer warns about missing PATH directories, so 2>/dev/null hid nothing and could hide a real set error), remove the stale comment, use $NODE_VIRTUAL_ENV/__MOD_NAME__/.bin for consistency with the NODE_PATH lines, and add a template-level regression test that does not need fish installed. Existing environments keep the old activate.fish until recreated with --force.

pytest tests/test_install_activate.py tests/test_activate_shells.py

97 passed / 36 skipped (zsh+fish not installed here).

@r3wretrhy
r3wretrhy force-pushed the fix/fish-path-caret-redirect-400 branch from 46f5d31 to b04b26d Compare October 3, 2026 11:13
@ekalinin

ekalinin commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Thanks for the fix! A few suggestions before merging:

  1. Drop the redirect instead of rewriting it (nodeenv.py:2171). Since fish 3.0, fish no longer warns about PATH directories that don't exist (Add better protection to setting $PATH  fish-shell/fish-shell#2969). So 2>/dev/null hides nothing, and it could hide a real set error. With the redirect removed, the fish tests still pass and sourcing activate.fish writes nothing to stderr.
  2. Update or remove the comment above that line (nodeenv.py:2169-2170). It says the missing node_modules/.bin directory makes fish print a warning, which hasn't been true since fish 3.0.
  3. Fix the affected fish versions in CHANGES, the commit message and the PR description. Fish 3.0 still treated ^ as a redirect by default. stderr-nocaret became the default in 3.1 and read-only in 3.3, so the bug affects fish 3.1 and later, not "fish 3+".
  4. CHANGES wording (CHANGES:9). "use 2>/dev/null instead" reads like advice to users. It would also help to mention that existing environments keep the old activate.fish until they are recreated with --force.
  5. Optional: a template-level test. The only regression guard is the shell test (tests/test_activate_shells.py:295-296), which is skipped when fish isn't installed. A check in tests/test_install_activate.py that the generated activate.fish has no ^/dev/null would catch a regression without fish.
  6. Nit: the edited line (nodeenv.py:2171) still hardcodes $NODE_VIRTUAL_ENV/lib/node_modules/.bin, while the NODE_PATH lines just below (nodeenv.py:2173-2174) use __MOD_NAME__. Using $NODE_VIRTUAL_ENV/__MOD_NAME__/.bin would keep them consistent.

fish 3.1+ defaults to stderr-nocaret, so a trailing ^/dev/null on the
PATH set line became a literal PATH entry. Drop the redirect entirely
(fish 3.0+ no longer warns about missing PATH dirs), remove the stale
comment, use __MOD_NAME__ for the .bin path, and add a template-level
regression test that does not need fish installed. Existing envs keep
the old activate.fish until recreated with --force.

Fixes ekalinin#400
@r3wretrhy
r3wretrhy force-pushed the fix/fish-path-caret-redirect-400 branch from b04b26d to 2867b39 Compare October 3, 2026 18:56
@r3wretrhy

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review — addressed all six points on tip 2867b39:

  1. Dropped the redirect on the PATH set line (no 2>/dev/null).
  2. Removed the obsolete comment about the missing node_modules/.bin warning.
  3. Corrected the affected versions to fish 3.1+ in CHANGES, the commit message, and the PR description.
  4. Reworded CHANGES so it no longer reads like user advice, and noted that existing envs keep the old activate.fish until recreated with --force.
  5. Added test_activate_fish_has_no_caret_redirect in tests/test_install_activate.py (no fish required).
  6. Switched the .bin path to $NODE_VIRTUAL_ENV/__MOD_NAME__/.bin.

Local: pytest tests/test_install_activate.py tests/test_activate_shells.py → 97 passed / 36 skipped (fish/zsh not installed here).

@ekalinin
ekalinin merged commit 54ecd2f into ekalinin:master Oct 3, 2026
26 checks passed
@ekalinin

ekalinin commented Oct 3, 2026

Copy link
Copy Markdown
Owner

Thanks!

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.

activate.fish leaves a literal ^/dev/null entry in PATH

2 participants