-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Code mangles PATH variable that it's opened with #56125
Comments
(Experimental duplicate detection) |
Does not seem to be related to 30847. |
What do you see when you type |
The same- whatever my base system path is, with whatever prepended customizations somehow appended instead. |
@alexwhittemore how did you launch VS Code? Also what's your PATH when you run |
In a system terminal (looks like VMWare did something since last I was testing this):
typically I'd When I do that, I get this in the Code terminal:
I'm not quite sure what EDIT: I realize now what it does, but anyway, the child shell seems to launch with the same environment (which I'd expect). |
@alexwhittemore can you also try this? echo $PATH
export PATH="/Users/alexw/Desktop:$PATH"
bash -l
echo $PATH I'm trying to identify whether code is running your login shell script again which is pushing Relevant code pointer: |
Ohhhhhhh interesting. That certainly looks to be what's happening: Alexs-MBP-2018:~
› echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public
Alexs-MBP-2018:~
› export PATH="/Users/alexw/Desktop:$PATH"
Alexs-MBP-2018:~
› bash -l
Alexs-MBP-2018:~
› echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Users/alexw/Desktop Also: oooh pretty highlighting. TIL. |
Related/duplicate of #55144 ? (Which I made a PR for that you're welcome to test) |
@segevfiner I'm not sure about duplicate, but it sounds like it's related enough that perhaps your PR fixes it? I've never compiled so much as an electron hello world, so I'm not sure how to go about testing your PR myself, but if I get a little more time than I have now, I'll look into it. In the mean time, if you'd be willing to try it for me, the test case is pretty straightforward: (system terminal:) $ export PATH=~/Desktop:$PATH
$ echo $PATH
# should spit back "/Users/You/Desktop:/rest/of/your/PATH"
$ code . (at code integrated terminal:) $ echo $PATH
# if failed:
# /rest/of/your/path:/Users/You/Desktop
# If fixed:
# /Users/You/Desktop:/rest/of/your/path |
Hmm @segevfiner I just noticed a behavior that does make this seem highly related - if I launch |
@alexwhittemore I think given that bash -l repros this, you should be able to fix this by tweaking your launch scripts, you want to make them idempotent (don't break things if they're run multiple times). |
I think I'm confused - what launch scripts? And what about them would take a perfectly fine path and do this nonsense to it? EDIT: also, since this is reproducible on a completely stock, out of the box installation of macOS, are you suggesting that this is an issue with a stock OS configuration? EDIT EDIT: HMMMMM.
Could this be the cause of my anguish? Guess I need to read up on path_helper. That looks to be the only thing explicitly to do with $PATH (nothing interesting in EDIT EDIT EDIT: Anyway it surprises me greatly that this is the first time I, or apparently anyone, has run into this if the cause is something introduced in 2012... Anyway thank you for putting me on the right path, at the least! |
Linux handles the profile and rc scripts differently and imo in a superior way, Windows is completely different so I do think this is a mac only problem. Here are the main differences:
This caused a whole bunch of headaches a long time ago and I eventually caved and make macOS launch a login script within the terminal #20145 (comment), but that causes a whole bunch of other issues. I don't normally do what you're trying to do, but I'm sure there's a proper way you're meant to do it. I also recommend reading up on the difference between |
Related: #55194 |
So I think the end result here is that two things are conspiring against my "virtualenv + code ." workflow, making it nowhere near as effective on Mac as on Win or Linux:
I can work around that at least a couple different ways - set a breadcrumb like OLD_PATH when I activate a virtualenv, and restore that to $PATH in bashrc. Or detect custom path items and blindly restore them to the front of the line. Or, application-specific, detect VIRTUAL_ENV and reactivate it blindly. But then despite any of those, I still run into
So I guess the Code workflow is just inherently worse on Mac than Windows, until there's first-class support for virtualenvs in the vscode Python plugin :( |
I'd recommend joining the discussion over at #15452, also for Python specifically I'm not sure if the python extension has a nice workaround for handling virtualenv or not https://github.com/Microsoft/vscode-python |
My understanding is, at this juncture, it's a discussion-in-progress. |
They have a separate "Create Terminal" command that creates a terminal with the active Python environment. But due to API limitations, this is a separate command and as such by default terminals are created using VS Code's environment via the stock "Create Terminal" command. |
@segevfiner sure, you could replace the keybinding though if it's all you want to use: { "key": "ctrl+`", "command": "thepythoncommand" } You can even make this the default only when you have a Python file opened: { "key": "ctrl+`", "command": "thepythoncommand", "when": "editorLangId == 'python'" } |
Using Insiders, just to be certain (impacts current release also)
Steps to Reproduce:
With a completely virgin install of macOS
That is to say, somehow, at some point, Code is taking the first item(s?) in my PATH and tacking them on the end instead, which, of course, alters the entire behavior of any shells with the altered version.
Does this issue occur when all extensions are disabled?: Yes (none installed at all)
The text was updated successfully, but these errors were encountered: