Skip to content

Issues running in VS Code integrated terminal vs Terminal.app on macOS #245

Open

Description

@repentsinner

I'm running into what appears to be a similar issue as #242 within the VS Code integrated terminal, but everything is fine in Terminal.app. I'm unclear on what the differences are between the VS Code environment (or tmux environment) and Terminal.app. The error message being printed mirrors what @redsuperbat is seeing.

The following commands produce different output in the two environments, specifically for the nvm_current_version variable. I believe I'm up to date on fish/fisher/nvm.

Terminal.app

ritchie@chonkers ~> set -S | grep nvm_current_version
$nvm_current_version: set in global scope, exported, with 1 elements
$nvm_current_version[1]: |v22.17.1|
ritchie@chonkers ~> fish --version
fish, version 4.0.2-gf1456f9
ritchie@chonkers ~> fisher --version
fisher, version 4.4.5
ritchie@chonkers ~> nvm --version
nvm, version 2.2.18
ritchie@chonkers ~>

VS Code.app

ritchie@chonkers ~> set -S | grep nvm_current_version
$nvm_current_version: set in global scope, exported, with 1 elements
$nvm_current_version[1]: |v22.17.1|
$nvm_current_version: originally inherited as |v22.17.1|
ritchie@chonkers ~> fish --version
fish, version 4.0.2-gf1456f9
ritchie@chonkers ~> fisher --version
fisher, version 4.4.5
ritchie@chonkers ~> nvm --version
nvm, version 2.2.18
ritchie@chonkers ~>

config.fish:

set -gx nvm_default_version lts

When conf.d/nvm.fish is loaded by fisher (?), nvm_current_version has already been set by something that VS Code then inherited, and the initial nvm use --silent $nvm_default_version is never executed. if I update that block to the following, everything seems to now work in VS Code and Terminal.app.

if set --query nvm_current_version
    set -e nvm_current_version
end
if status is-interactive && set --query nvm_default_version && ! set --query nvm_current_version
    nvm use --silent $nvm_default_version
end

I went chasing all over various dotfiles as well as VSCode's settings.json and I don't see where nvm_current_version is being set upstream of fish initialization, and why it would be inherited to VS Code and not Terminal.app.

Is there any issue unsetting nvm_current_version in the conf.d/nvm.fish file? I'm not super clear on initialization order of fish/fisher.

Activity

  1. changed the title [-]Issues running in VS Code terminal vs Terminal.app on macOS[/-] [+]Issues running in VS Code integrated terminal vs Terminal.app on macOS[/+] on Jul 26, 2025
  2. thewirv commented on Apr 2, 2026

    @thewirv

    I am having the same problem using Zed on Arch Linux, where nvm_current_version is always being set to system (which is node@latest due to package dependencies). In the integrated terminal (which is Alacritty), I always experience this behavior, while in Ghostty I do not.

  3. evaporei commented on May 9, 2026

    @evaporei

    I had to add this to ~/.config/fish/config.fish.

    if status is-interactive
        if functions -q nvm
            nvm use default >/dev/null 2>&1
        end
    end

    Switch default with whatever version you use.

  4. jorgebucaran commented on May 11, 2026

    @jorgebucaran
    Owner

    Yeah, that should do the trick 👍

  5. thewirv commented on May 12, 2026

    @thewirv

    a) That does not work for me, it still "falls back" to the system version.
    b) This would only have been a workaround for me, as it would be annoying to be forced to go into config.fish and change the version every time you update Node
    c) The only thing that works for me is the following:

    ➜ set -e nvm_current_version && nvm use 24.15.0
    Now using Node v24.15.0 (npm 11.13.0) ~/.local/share/nvm/v24.15.0/bin/node

    I have to do that on every new shell that opens up, which is very annoying (although you get used to it after some time).

  6. damner commented on Oct 24, 2026

    @damner

    Same here with Zed on macOS (fish 4.9.3, nvm.fish from main, Zed 1.25.3). I think I found the cause.

    Cause. When Zed starts from the Dock, it captures the environment by running fish -l -i -c '…; zed --printenv' (shell_env.rs). That shell is interactive, so conf.d/nvm.fish runs nvm use and exports nvm_current_version. Zed then passes this variable to every terminal it opens.

    In the terminal, the new login fish rebuilds PATH, and fish_user_paths (here it has /opt/homebrew/bin) goes to the front. Then conf.d/nvm.fish sees that nvm_current_version is already set and skips nvm use. So the nvm bin dir stays behind Homebrew, and node is Homebrew's. In Ghostty the variable is not inherited, so nvm use runs and nvm wins.

    Repro (no Zed needed):

    env -i HOME=$HOME TERM=xterm nvm_current_version=v26.10.0 \
        PATH=/usr/bin:/bin:/opt/homebrew/bin:$HOME/.local/share/nvm/v26.10.0/bin \
        fish -l -i -c 'type -a node'
    # node is /opt/homebrew/bin/node   <- first

    Workaround. This puts the inherited version back at the front, so you don't need to hardcode a version:

    # ~/.config/fish/conf.d/nvm_inherited.fish
    if status is-interactive; and set --query nvm_current_version[1]; and set --query nvm_data
        and test -d $nvm_data/$nvm_current_version/bin
        fish_add_path --global --prepend --move --path $nvm_data/$nvm_current_version/bin
    end

    The same thing likely happens in any fish started from another fish-spawned process (VS Code, WebStorm, tmux). A possible fix in nvm.fish itself: in conf.d/nvm.fish, when nvm_current_version is inherited, move its bin to the front of PATH instead of skipping it.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions