Skip to content
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

Windows Terminal does not check new PATH variables #12214

Closed
Tydoki opened this issue Jan 22, 2022 · 12 comments
Closed

Windows Terminal does not check new PATH variables #12214

Tydoki opened this issue Jan 22, 2022 · 12 comments
Labels
Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Product-Terminal The new Windows Terminal. Resolution-No-Repro We couldn't get this to happen, or it stopped happening entirely.

Comments

@Tydoki
Copy link

Tydoki commented Jan 22, 2022

Windows Terminal version

1.11.3471.9

Windows build number

10.0.22000.0

Other Software

tested with ffmpeg and yt-dlp

Steps to reproduce

  1. Add any folder to your path variable with an exe in it
  2. Open Windows Terminal
  3. Run that exe from within windows terminal (powershell or cmd)

Expected Behavior

exe runs

Actual Behavior

The term 'X' is not recognized as a name of a cmdlet... etc

With windows terminal set as default I can simply click "powershell 7", in my start menu" and it opens within windows terminal. And for some reason that first tab works. This issue only occurs when I open Windows Terminal by clicking "Windows Terminal" or using any tab that isn't the first tab when opening it by clicking "powershell 7" .

These commands also work on powershell 7 or cmd when not used in Windows Terminal.

To get any new exe to work I have to either add the exe to a folder already in my PATH or add new folder as usual and then reinstall windows terminal for it to be recognized.

Note: Brand New PC (literally got today), Windows 11, Windows Terminal came preinstalled.

Sorry if this is just a me issue.

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Jan 22, 2022
@zadjii-msft
Copy link
Member

Wait so this isn't #1125 after all. That's weird. It's a known bug that the Terminal won't reload env vars while it's running, but that should only apply when you:

  1. Open the terminal
  2. add something to the PATH
  3. open another tab

Starting the terminal from cold (no existing windows / tabs) should reload the env vars, and they shouldn't change while the Terminal is running.

Maybe this has to do with the way the Terminal is invoked via defterm, when you launch pwsh directly and it opens magically in the Terminal. Hmm.

@zadjii-msft zadjii-msft added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Product-Terminal The new Windows Terminal. labels Jan 24, 2022
@Tydoki
Copy link
Author

Tydoki commented Jan 25, 2022

Yeah from cold start it didn't work.

I've been installing things since this is a new pc and somewhere along the line tho is started to work...

But yeah it was like that for the 3 hours I was trying to fix it.

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Jan 25, 2022
@zadjii-msft
Copy link
Member

and somewhere along the line tho is started to work

Weird. Well at least it's working now? Maybe it's possible that the defterm COM server was still hanging around to service new defterm requests, so it wasn't as cold a launch as it might have seemed. Hard to know for sure. Glad the issue went away at least!

@zadjii-msft zadjii-msft added the Resolution-No-Repro We couldn't get this to happen, or it stopped happening entirely. label Jan 25, 2022
@TommyCox
Copy link

TommyCox commented Feb 7, 2022

I also am having this issue on a new installation after installing GitHub CLI with winget.

Windows Terminal Version: 1.12.10334.0
Windows Build: 10.0.22543.1000

I tried restarting and killing Windows Terminal from Task Manager a few times to no effect.
Old terminals can find the executable, but not Windows Terminal.

image

@zadjii-msft
Copy link
Member

@TommyCox what's the PATH when running the Terminal, vs running cmd.exe directly?

Does the PATH in Terminal change depending on if it's launched from the Run Dialog (Win+R) vs the Start Menu? (#11777 is the one I'm thinking of)

@TommyCox
Copy link

TommyCox commented Feb 8, 2022

@zadjii-msft Yes, that seems to be the case.

I didn't check the PATH directly, but powershell (Windows Terminal) was able to find executables on the updated path after relaunching from a taskbar icon instead of wt.exe. This also seems to update the path for future wt.exe launches as well.

@cforce
Copy link

cforce commented Dec 9, 2022

zadjii-msft @TommyCox
Why is this closed - I have the same issue
I can start a new cmd from windows start menu and my user PATH is loaded
If i do the same ( same cmd and params) via terminal it doesn't reflect the PATH changes.
I can open a dozens new terminal windows cmd windows from the same running terminal parent instance - issue still remains.
It seems toi recover when i completly terminate the terminal parent and create a new and a new cmd window . so its terminal app caching the context. Do you use some cached state of context?
How to enforce REAL (re)loadind onf env?
My workaround is now to use choco's "refreshenv" .. but5 hey this is defintetly a bug in the terminal application so please reopen this issue.

@zadjii-msft
Copy link
Member

This was closed because OP's issue ultimately resolved itself. The issue you're describing is tracked in #1125

@Ares9323
Copy link

relaunching from a taskbar icon instead of wt.exe. This also seems to update the path for future wt.exe launches as well.

I can confirm that launching from wt.exe doesn't load the new environmental variables, launching it from the taskbar icon or the start menu icon works fine, but in my case the PATH is not updated if I open the wt.exe again

@ktzsolt
Copy link

ktzsolt commented Mar 31, 2023

I also struggled with this issue, I had set up env var for User and Machine scope but it was only visible with echo $env:PATH when I launched a powershell window directly but not from a PS tab launched from windows terminal.

I even closed and reopened the whole windows terminal with no luck, but then I opened up task manager and saw that when I close the windows terminal it is not yet closed but it stays alive for as long as 30 seconds as a process with one Runtime Broker subprocess and when you reopen windows terminal you open up again that previous process that still doesn't have the new environment variables.

So the solution is to close windows terminal and wait 30-60 seconds before you open it op (or kill the process from task manager).

@mithom
Copy link

mithom commented Jun 27, 2023

this issue still exists... restarted terminal multiple times, PATH doesn't update, opening a regular cmd or powershell does show the new path.

@lhecker
Copy link
Member

lhecker commented Jun 27, 2023

The fix (#14999) is only available in Windows Terminal Preview 1.18. Are you sure you're using that version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Attention The core contributors need to come back around and look at this ASAP. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Product-Terminal The new Windows Terminal. Resolution-No-Repro We couldn't get this to happen, or it stopped happening entirely.
Projects
None yet
Development

No branches or pull requests

8 participants