sourcegit-scm / sourcegit

Windows/macOS/Linux GUI client for GIT users
MIT License
610 stars 66 forks source link

"Open in Terminal" cannot find "wt.exe" #197

Closed ZaLiTHkA closed 2 weeks ago

ZaLiTHkA commented 2 weeks ago

I'm running Windows 11 Pro 23H2, with Windows Terminal 1.20.11381.0 installed through the Microsoft Store.

with SourceGit 8.17, I get the following error popup when I click the "Open in Terminal":

image

NOTE: it seems like this is only an issue if SourceGit is configured to use "Default Shell in Windows Terminal", if I explicitly select a shell ("Git Bash", "PowerShell", or "Command Prompt") then I get the expected shell in a new tab in WT.

the only difference I see with explicitly selecting "PowerShell" for this, is the tab itself shows the full path to pwsh.exe whereas creating a new tab in WT directly just says "PowerShell".

image

first tab opened by SourceGit, second tab opened in WT directly.

love-linger commented 2 weeks ago

This software uses the PATH environment variable to find the location of wt.exe.

ZaLiTHkA commented 2 weeks ago

This software uses the PATH environment variable to find the location of wt.exe.

fair enough, and that is a pretty standard way of handling access to applications that may or may not be installed, or that can be installed to anywhere the user chooses.. obviously this is also why explicitly selecting "PowerShell" as the shell to use works, because in my system the folder with pwsh.exe is in my PATH environment variable.

the problem here is that Windows Terminal installs to C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_<VERSION>_x64__<IDENTIFIER>, as seen in my screenshot of Explorer:

image

but this C:\Program Files\WindowsApps, at least in Windows 11, seems to be some new kind of special folder.. I can navigate to the folder seen above if I "open file location" from the WT process in Task Manager, but trying to navigate there from my "C:" in Explorer shows up as a hidden folder (which I always keep visible anyway) and then simply refuses to open.

furthermore, while it may work to explicitly add this to my PATH variable, because in includes a version number, this path will change when WT is updated. so that's not a valid solution.

there must be a better way to launch WT, but I'm not sure how to make use of that from an app built using C#.. I am currently at work and busy with other things, but I've made a note to dig into this some more when I get home later.

gadfly3173 commented 2 weeks ago

It looks like the only way to specify a window title for PowerShell launched via Process.Start is to add the argument - Command "& { $Host.UI.RawUI.WindowTitle = 'My Custom Title'; }", the PowerShell window title you see when you manually open pwsh seems to be a special behavior of Windows itself.

ZaLiTHkA commented 2 weeks ago

alrighty, I think I've figured it out.. I had a "simple" environment config issue on my end.

when I checked my Windows 10 system, specifically I found an entry for %USERPROFILE%\AppData\Local\Microsoft\WindowsApps in my PATH variable. checking this folder, I see what appear to be shims of some kind to the "currently installed versions" of my Windows Store apps, such as the folder path I found earlier.

adding this path to the PATH variable in my Windows 11 machine exposed wt.exe (and a bunch of other things that I was looking for) to my environment, and now SourceGit's "open in terminal" action works with the "Default profile in Windows Terminal" option.

definitely not a bug.. 🎉 maybe worth adding a note to the readme though? it could fit in quite nicely with the other environment-related config info.