Typing in the Visual Studio Code Terminal Is Somehow Slow

Check whether PATH has ballooned


Posted on Sun, Jan 5, 2025
Tags vscode, terminal, zsh
vscode, terminal, zsh
📝 This article is a translation of the original Japanese post. View original

The Slow Typing in the VS Code Terminal Started to Bother Me

  • Environment: Windows (WSL2)
  • Shell: zsh

While using VS Code on a new machine, typing commands in the terminal (zsh) became remarkably slow. Related to that, zsh: argument list too long was occurring when running commands. (This can happen in zsh when an environment variable is very long.)

Looking into it, the contents of the PATH environment variable were absurdly long, with the same values repeated four or five times.

1
/home/me/.vscode-server/bin/fabdb6a30b49f79a7aba0f2ad9df9b399473380f/bin/remote-cli:/home/me/.krew/bin:/home/me/go/1.23.3/bin:/home/me/.anyenv/envs/goenv/shims:/home/me/.anyenv/bin:/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/Alacritty/:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/Tailscale/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/dotnet/:/mnt/c/Users/me/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/me/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/me/AppData/Local/Muse Hub/lib:/home/linuxbrew/.linuxbrew/opt/node@22/bin:/home/me/go/1.23.3/bin:/home/me/.anyenv/envs/goenv/shims:/home/me/.anyenv/bin:/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/Alacritty/:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/Tailscale/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/dotnet/:/mnt/c/Users/me/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/me/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/me/AppData/Local/Muse Hub/lib:/home/me/.local/share/pnpm:/home/me/go/1.23.3/bin:/home/me/.anyenv/envs/goenv/shims:/home/me/.anyenv/bin:/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/Alacritty/:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/Tailscale/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/dotnet/:/mnt/c/Users/me/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/me/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/me/AppData/Local/Muse Hub/lib:/home/linuxbrew/.linuxbrew/opt/node@22/bin:/home/me/go/1.23.3/bin:/home/me/.anyenv/envs/goenv/shims:/home/me/.anyenv/bin:/home/linuxbrew/.linuxbrew/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/Alacritty/:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/Tailscale/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/dotnet/:/mnt/c/Users/me/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/me/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/me/AppData/Local/Muse Hub/lib:/home/linuxbrew/.linuxbrew/bin:/home/me/.anyenv/bin:/home/me/go/bin:/home/me/.anyenv/envs/goenv/shims:/home/me/go/1.23.3/bin:/home/linuxbrew/.linuxbrew/opt/node@22/bin:/home/me/.local/share/pnpm:/home/me/.krew/bin

Looking at the contents of PATH, it appears repetitive, but the paths that get loaded differ subtly. If you have zsh plugins such as auto suggestion installed, a PATH with a lot of useless entries is a likely suspect for making executable path resolution slow.

I wasn’t able to pin down the cause, but it seems .zshrc gets loaded several times under different conditions. My terminal is Linux, but Why are there duplicate paths in the terminal’s $PATH environment variable and/or why are they reversed on macOS? was a useful reference.

It isn’t a root-cause fix, but disabling Terminal › Integrated: Inherit Env prevents the repeated loading.

Whether new shells should inherit their environment from VS Code, which may source a login shell to ensure $PATH and other development variables are initialized. This has no effect on Windows.

The PATH of the terminal that launched became roughly the same as that of other terminals.

1
/home/me/.vscode-server/bin/fabdb6a30b49f79a7aba0f2ad9df9b399473380f/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/Alacritty/:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/Tailscale/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/dotnet/:/mnt/c/Users/me/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/me/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/me/AppData/Local/Muse Hub/lib:/home/linuxbrew/.linuxbrew/bin:/home/me/.anyenv/bin:/home/me/.anyenv/envs/goenv/shims:/home/linuxbrew/.linuxbrew/opt/node@22/bin:/home/me/.local/share/pnpm:/home/me/.krew/bin

With that, zsh command completion got faster.

Share