-
Notifications
You must be signed in to change notification settings - Fork 28.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect $PATH order in task shell #187955
Comments
can you reproduce the issue in insider's? |
@meganrogge yes, it is happening there too, fresh Insider install. Version: 1.81.0-insider (Universal) |
For the record, here are my two From Task
From Terminal
Note: the task dedups the paths and changes the order, otherwise they are the same paths. |
thanks, it's unlikely i'll get to this issue soon. if you're curious, you can poke around the code and try to figure out why this is the case. it might be by design. I'm not sure why it would be breaking anything for you though 🤔 |
maybe here... vscode/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts Lines 1240 to 1245 in a06ece3
|
@meganrogge I wonder if it's due to this commit. Not sure if this is in 1.80. ca9192e It's strange that the PR this commit references (#186938) seems to just be for performance but the commit seems to remove fetching the shell env. |
Changing the order of the path breaks a lot of things for me, it is loading system versions of things like Ruby etc instead of my local ones 😅 I tried to override the behavior with options.env.PATH but that gets blown away too. I am a little surprised that there's not more activity on this issue, my environment must be weirder than I thought, because I thought this would have blown a lot of people up |
I think this one is probably related: #186244 I'm also adopting the |
Looks like that issue is for 1.79 but I only noticed this after upgrading to 1.80. Unsure if they are the same. |
do you have can you enable trace logging and share the output for the (IE run the command developer set logging, choose |
Yes. However I've tested it with and without this enabled and it has the same issue both ways.
I ran this on the Insiders build. Here's the ptyHost output
Here's the terminal output.
Note the logs included some sensitive env vars that I redacted. |
thanks for the logs. @Tyriar I find it weird that right after
|
@meganrogge I tested it again and same create/shutdown lines in the log. I didn't reload the window. |
On a hunch, I simplified my
It still appends the path to the end instead of the beginning.
However there's no longer a shutdown line in the log.
This is all on Insiders build. |
@meganrogge here's some more testing to try to make sense of what it's doing. # ~/.zshrc
PATH="/a:$PATH"
PATH="$PATH:/b"
PATH="/c:$PATH" Here's the output: # VS Code Task for `echo $PATH`
/usr/local/bin:...:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/c:/a:/b
# VS Code Terminal
% echo $PATH
/c:/a:/usr/local/bin:...:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/c:/a:/b:/b
# OS X Terminal
% echo $PATH
/c:/a:/usr/local/bin:...:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/b It's as if The VS Code terminal seems to use the resulting I tried disabling inheritEnv setting and it has the same output. |
oh, what happens if you disable shell integration |
@meganrogge shutdown and relaunch is expected if an extension changes an environment variable collection |
Disabled shell integration and restarted Insiders app. Same output. # VS Code Task
/usr/local/bin:...:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/c:/a:/b
# VS Code Terminal
echo $PATH
/c:/a:/usr/local/bin:...:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/c:/a:/b:/b Another interesting note. OS X uses # OS X Terminal
% . /etc/profile
% echo $PATH
/usr/local/bin:...:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/c:/a:/b This is because |
This is a fresh Insiders install with no extensions enabled. Interestingly the relaunch was related to something in my ~/.zshrc setup. |
@ryanb in which case I think it is expected since the builtin git extension uses this API |
@ryanb that only removes its use from The actual shell proc's environment is sourced here: vscode/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts Lines 430 to 436 in ce25797
|
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines. Happy Coding! |
@meganrogge @Tyriar can you reopen this issue? It's still a problem. What information do you need from me to help resolve it? |
I have the same issue. Version: 1.81.1
Date: 2023-08-09T22:18:39.991Z
Electron: 22.3.18
ElectronBuildId: 22689846
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Linux x64 6.4.11-arch2-1 Commit: 6c3e3db
{
"version": "2.0.0",
"tasks": [
{
"label": "echo PATH",
"type": "shell",
"command": "echo $PATH | tr ':' '\\n'"
}
],
} Executing the task * Executing task: echo $PATH | tr ':' '\n'
/usr/local/bin
/usr/bin
/usr/local/sbin
/var/lib/flatpak/exports/bin
/usr/bin/site_perl
/usr/bin/vendor_perl
/usr/bin/core_perl
* Terminal will be reused by tasks, press any key to close it. From terminal $ echo $PATH | tr ':' '\n'
/home/us-er/.local/share/rtx/installs/node/18.17.1/bin
/home/us-er/.local/share/rtx/installs/go/1.21.0/go/bin
/home/us-er/.local/share/rtx/installs/go/1.21.0/packages/bin
/home/us-er/.local/share/rtx/installs/java/openjdk-17/bin
/home/us-er/.local/share/rtx/installs/nim/2.0.0/bin
/home/us-er/.local/share/rtx/installs/nim/2.0.0/nimble/bin
/home/us-er/.local/share/rtx/installs/rust/1.72.0/bin
/home/us-er/.local/share/rtx/installs/bin/0.17.0/bin
/home/us-er/.local/share/rtx/installs/pipx/1.2.0/bin
/home/us-er/.local/share/rtx/installs/zig/0.11.0/bin
/home/us-er/.local/share/rtx/installs/shfmt/3.7.0/bin
/home/us-er/.local/share/rtx/installs/ninja/1.11.1/bin
/home/us-er/.local/share/rtx/installs/neovim/0.9.1/bin
/home/us-er/.local/share/rtx/installs/kotlin/1.9.10/kotlinc/bin
/home/us-er/.local/share/rtx/installs/kotlin/1.9.10/kotlin-native/bin
/home/us-er/.local/share/rtx/installs/cmake/3.27.4/bin
/home/us-er/.local/share/rtx/installs/meson/1.2.1/bin
/home/us-er/.local/share/rtx/installs/shellcheck/0.9.0/bin
/usr/local/bin
/usr/bin
/usr/local/sbin
/var/lib/flatpak/exports/bin
/usr/bin/site_perl
/usr/bin/vendor_perl
/usr/bin/core_perl
/home/us-er/.local/bin Current work around:
# ~/.zprofile
# Import the default profile
if [ -f "/etc/profile" ]; then
# shellcheck disable=SC1091
. "/etc/profile"
fi
# Append "$1" to $PATH when not already in.
append_path() {
case ":$PATH:" in
*:"$1":*) ;;
*)
export PATH="${PATH:+$PATH:}$1"
;;
esac
}
# user-paths
append_path "$HOME/.local/bin"
eval "$(/usr/bin/rtx activate zsh)"
#append_path "$HOME/.local/share/rtx/shims" # slower
unset -f append_path |
This is also a problem for me when using Conda python environments because the system version of python is selected instead of the version used in the environment. macOS terminal:
Inside vscode task:
|
Also having the same issues VSCode integrated Terminal:
tasks.json
|
This worked as expected with the following version of vscode:
And was broken on the following version:
|
@ryanb can you pls test in insider's to see if this is still an issue for you? |
This does not work for me on latest insider:
|
@meganrogge yes, it's still an issue for me. Since this original post I've got a new MacBook Pro (M3 Silicon) and simplified my ZSH dot files. Here's the output of
Here's the output of
This is the version of VS Code.
|
FYI I had the same issue in #186244 My workaround is to explicitly |
The This moves the conda environment path to the front of the
|
This issue also happened to me when trying to set a task to run my project. Thank you @coffenbacher ! |
This also affects extensions that call out to executables, that need PATH to be in whatever state the user specified in their shell profile. For instance formatting by latexindent on latexworkshop, which is provided by a conda base environment. |
same problem... I patched on my machine by adding the following to my "terminal.integrated.profiles.osx": { "zsh": { "path": "/bin/zsh", "args": ["-l", "-i"] } } |
Type: Bug
I have a custom task in
tasks.json
. Since upgrading to 1.80 it's loading my$PATH
env variable in an incorrect order.I have tested this by adding this task in
tasks.json
.When I run this task it shows a different
$PATH
than when I choose New Terminal within VS Code and runecho $PATH
. The paths themselves appear the same, just in a different order which is causing issues with finding the proper bins.I'm on Mac OS X 13.3 and use zsh.
VS Code version: Code 1.80.1 (Universal) (74f6148, 2023-07-12T17:20:23.298Z)
OS version: Darwin x64 22.4.0
Modes:
System Info
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Extensions (12)
(1 theme extensions excluded)
A/B Experiments
The text was updated successfully, but these errors were encountered: