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

Path variable from the environment is not respected #18026

Closed
0xEDApps opened this issue Oct 10, 2024 · 11 comments
Closed

Path variable from the environment is not respected #18026

0xEDApps opened this issue Oct 10, 2024 · 11 comments
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.

Comments

@0xEDApps
Copy link

Windows Terminal version

1.22.240926002-preview

Windows build number

10.0.22621.819

Other Software

No response

Steps to reproduce

run:
cmd.exe
type:
set path=c:\tweet;%path%
type your path to terminal:
"C:\Users\Admino\AppData\Local\Temp\WindowsTerminal\x64\WindowsTerminal.exe"
open a cmd window in terminal and type:
path

WindowsTerminal.exe shows the right path "c:\tweet;...."
OpenConsole.exe also shows the right path "c:\tweet;...."
but then cmd.exe has a different path

Expected Behavior

to see the active environment
to see "c:\tweet"

Actual Behavior

shows the wrong path
probably the environment is retrieved from the registry instead of the environment

@0xEDApps 0xEDApps added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Oct 10, 2024
@0xEDApps
Copy link
Author

Checked with ProcessHacker to see the environment of individual executables

WindowsTerminal.exe shows the right path "c:\tweet;...."
OpenConsole.exe also shows the right path "c:\tweet;...."
cmd.exe has a different path

@0xEDApps 0xEDApps reopened this Oct 10, 2024
@lhecker
Copy link
Member

lhecker commented Oct 10, 2024

Windows Terminal treats each tab and pane like a "container" of sorts. Each one gets its own fresh environment variables. You can disable that behavior here:

Image

@0xEDApps
Copy link
Author

i see, indeed that works for new tabs but not for the one that is there when launched.

i also use these settings
default profile: Command Prompt
when terminal starts: open tab with default profile

@0xEDApps
Copy link
Author

Also it does not show the correct path wen a tab is created with a new instance.

i have this setting
new instance behavior: attach to the most recently used window

@carlos-zamora
Copy link
Member

Thanks for filing! Assuming Windows Terminal is set as your default terminal, start cmd should create a new window and immediately hand off to windows terminal, which would then have the expected environment block. This can be used as a workaround for your scenario. If you do wt new-tab -w0 cmd, that should work too. Does that work for you ?

Note #16226 may be involved here.

@carlos-zamora carlos-zamora added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Oct 16, 2024
@0xEDApps
Copy link
Author

Thanks for filing! Assuming Windows Terminal is set as your default terminal

Don't even know how to do that, it most likely can't be automated as MS implemented encryption for default file associations, so no it is not the default

Does that work for you ?

it does, but not my preferred solution

Note #16226 may be involved here.

Good find buddy
Indeed, seems to be a reoccurring issue, you can not expect all users to start hunting for command line parameters, when the default behaviour is that a app inherits the environment from the caller.
I used --inheritEnvironment from there as the cleaner outcome

To bad MS does not respect the environment and reads the registry instead, now many other devellopers also do that, a example WindowsTerminal writes to %LocalAppdata% but uses the one from the registry, i am not gonna mess with that, i attempted it years ago, but that is a global change and all other crappie apps will start to write at the new location too, so sad :(
Maybe that should be a different issue.

@microsoft-github-policy-service microsoft-github-policy-service bot 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 Oct 17, 2024
@DHowett
Copy link
Member

DHowett commented Oct 17, 2024

i am not gonna mess with that, i attempted it years ago, but that is a global change and all other crappie apps will start to write at the new location too, so sad :(
Maybe that should be a different issue.

You must know that redirecting the known folders like AppData/LocalAppData is not supported. Please don't file bugs on us, or anyone else, for that.

@DHowett
Copy link
Member

DHowett commented Oct 17, 2024

Thanks for filing! Assuming Windows Terminal is set as your default terminal

Don't even know how to do that, it most likely can't be automated as MS implemented encryption for default file associations, so no it is not the default

Windows Terminal is the default console host on your version of Windows unless you've turned it off explicitly, and it does not work by using "file associations".

@0xEDApps
Copy link
Author

Windows Terminal is the default console host on your version of Windows unless you've turned it off explicitly, and it does not work by using "file associations".

Doubt that, i am on win 11 and never have i seen "windows terminal" it always shows cmd.exe or consolehost.exe

@DHowett
Copy link
Member

DHowett commented Oct 23, 2024

At its heart, this is a /duplicate of #15496.

You can use the --inheritEnvironment argument or the profile setting compatibility.reloadEnvironmentVariables (set to false).

Copy link
Contributor

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@microsoft-github-policy-service microsoft-github-policy-service bot added Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Attention The core contributors need to come back around and look at this ASAP. labels Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.
Projects
None yet
Development

No branches or pull requests

4 participants