Skip to content

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

Description

@ekalinin

Summary

bin/activate.fish appends a bogus ^/dev/null element to PATH. Every
fish user of nodeenv gets it. The same one-line bug also defeats the stderr
suppression the line was written for.

Reproduction

$ nodeenv --prebuilt /tmp/ne
$ fish -c 'source /tmp/ne/bin/activate.fish; string join \n $PATH | tail -1'
^/dev/null

Observed in CI on ubuntu-latest as a fourth PATH entry resolving to
<cwd>/^/dev/null.

Cause

ACTIVATE_FISH ends its PATH line with a caret redirect:

# The node_modules/.bin path doesn't exists and it will print a warning, and
# that's why we redirect stderr to /dev/null :)
set -gx PATH "$NODE_VIRTUAL_ENV/lib/node_modules/.bin" "$NODE_VIRTUAL_ENV/__BIN_NAME__" $PATH ^/dev/null

fish 3.0 introduced the stderr-nocaret feature flag and ^ stopped being
a stderr redirect; it is now an ordinary character. So ^/dev/null is
parsed as one more argument to set and lands in PATH.

Two consequences, not one:

  1. PATH gains an entry that does not exist.
  2. The warning the redirect was meant to hide now reaches stderr, so the
    comment above the line no longer describes what happens.

nodeenv.py uses the same ^/dev/null syntax once more, inside freeze:

set -g NPM_LIST (npm list installed active >/dev/null ^/dev/null | \
                 cut -d ' ' -f 1 | grep -v npm)

Both should be fixed together. The modern spelling is 2>/dev/null.

Test coverage

tests/test_activate_shells.py (added in #397) marks this
xfail(strict=True) as FISH_CARET_REDIRECT on test_activate_sets_env,
via the path_shell decorator. When the fix lands, drop the constant and the
decorator and put the test back on @activating_shell.

Worth noting how it surfaced: the test originally asserted only the first two
PATH entries, which hid this completely and let CI report green. Widening
it to compare the whole list caught the bug on the first run. A regression
anywhere past index 1 was previously invisible.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions