startingDirectory being invalid shouldn't cause silent failures #13967

Closed
opened 2026-01-31 03:57:16 +00:00 by claunia · 12 comments
Owner

Originally created by @randomascii on GitHub (May 27, 2021).

Originally assigned to: @DHowett on GitHub.

Windows Terminal version (or Windows build number)

1.8.1444.0

Other Software

No response

Steps to reproduce

Adjust the startingDirectory to the name of a directory that doesn't exist. Then launch Windows Terminal. That's it.

Expected Behavior

I was expecting an error message saying that the directory doesn't exist. This could be printed to the console or it could be a dialog. Ideally Windows Terminal would still launch since otherwise there is no clear way for me to fix this broken setting.

Actual Behavior

The Windows terminal window flashes and then closes. There is no indication of what the problem is and, unless you have memorized the path to the settings file, no way to fix the problem.

This issue can easily happen if you delete a directory or if you copy settings from one machine to another.

Originally created by @randomascii on GitHub (May 27, 2021). Originally assigned to: @DHowett on GitHub. ### Windows Terminal version (or Windows build number) 1.8.1444.0 ### Other Software _No response_ ### Steps to reproduce Adjust the startingDirectory to the name of a directory that doesn't exist. Then launch Windows Terminal. That's it. ### Expected Behavior I was expecting an error message saying that the directory doesn't exist. This could be printed to the console or it could be a dialog. Ideally Windows Terminal would still launch since otherwise there is no clear way for me to fix this broken setting. ### Actual Behavior The Windows terminal window flashes and then closes. There is no indication of what the problem is and, unless you have memorized the path to the settings file, no way to fix the problem. This issue can easily happen if you delete a directory or if you copy settings from one machine to another.
Author
Owner

@drkvogel commented on GitHub (May 27, 2021):

I don't understand all these bug reports @craigloewen-msft about windows terminal, cause it works perfectly for me! Good job! Glad you fixed the wsl clock thing! The News and Interests new "feature" in the tray is broken, but that's another story... where can I file a bug report about that?

@drkvogel commented on GitHub (May 27, 2021): I don't understand all these bug reports @craigloewen-msft about windows terminal, cause it works perfectly for me! Good job! Glad you fixed the wsl clock thing! The News and Interests new "feature" in the tray is broken, but that's another story... where can I file a bug report about that?
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (May 27, 2021):

In https://github.com/microsoft/terminal/issues/5214#issuecomment-618109094, it was mentioned that there was a plan to make Windows Terminal leave the session open if the process exits within five seconds. That would presumably cover invalid starting directories as well. However, I did not find an issue specifically for the five-second threshold feature.

@KalleOlaviNiemitalo commented on GitHub (May 27, 2021): In <https://github.com/microsoft/terminal/issues/5214#issuecomment-618109094>, it was mentioned that there was a plan to make Windows Terminal leave the session open if the process exits within five seconds. That would presumably cover invalid starting directories as well. However, I did not find an issue specifically for the five-second threshold feature.
Author
Owner

@zadjii-msft commented on GitHub (May 27, 2021):

leave the session open if the process exits within five seconds.

I think that's probably a good idea. It kinda conflicts with the idea of "closeOnExit": "always" though. The user specifically said "I want the tab to always close when the client app exits". it just so happens, this is one of those scenarios where the client app closes immediately, and that means the only tab is going to go away.

So I guess the philosophical question is "does closeOnExit: always also apply to the window, when there's only one tab immediately closing on exit", and that doesn't seem too bad to me.

Okay I've talked myself into it

@zadjii-msft commented on GitHub (May 27, 2021): > leave the session open if the process exits within five seconds. I think that's probably a good idea. It kinda conflicts with the idea of `"closeOnExit": "always"` though. The user specifically said "I want the tab to always close when the client app exits". it just so happens, this is one of those scenarios where the client app closes immediately, and that means the only tab is going to go away. So I guess the philosophical question is "does `closeOnExit: always` also apply to the window, when there's only one tab _immediately_ closing on exit", and that doesn't seem too bad to me. Okay I've talked myself into it
Author
Owner

@zadjii-msft commented on GitHub (May 27, 2021):

notes from Teams:

"The connection couldn't even be established" (state transitions from "Connecting" to "Failed" without passing through "Connected")
.... Pane just observes the state transitions?
"Old=Connecting -> New=Failed: do not close"

@zadjii-msft commented on GitHub (May 27, 2021): notes from Teams: "The connection couldn't even be established" (state transitions from "Connecting" to "Failed" without passing through "Connected") .... Pane just observes the state transitions? "Old=Connecting -> New=Failed: do not close"
Author
Owner

@JoBrad commented on GitHub (May 27, 2021):

I have exactly the opposite behavior, and I don't like it. My closeOnExit value is set to graceful (not sure how that plays into this). I had set the starting directory for both Ubuntu and Powershell to the value ~, since this works in either shell. But it didn't actually work, so I also had the commandline value for Ubuntu set to wsl.exe ~ -d Ubuntu. After updating to the most recent version of Windows Terminal Preview, I now get the error below, and the shell won't start:

[error 0x8007010b when launching `powershell.exe'] Could not access starting directory "C:\Users\UserName\AppData\Local\Microsoft\WindowsApps\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\~"

Setting the Startup directory to the parent process directory, or to %USERPROFILE% fixes the issue (and I still get put into my home directory, thanks to the commandline value).

But immediately exiting seems like a terrible way for the terminal to handle not finding a directory. It should at least default to the parent process directory, I think.

@JoBrad commented on GitHub (May 27, 2021): I have exactly the opposite behavior, and I don't like it. My closeOnExit value is set to graceful (not sure how that plays into this). I had set the starting directory for both Ubuntu and Powershell to the value `~`, since this works in either shell. But it didn't actually work, so I also had the commandline value for Ubuntu set to `wsl.exe ~ -d Ubuntu`. After updating to the most recent version of Windows Terminal Preview, I now get the error below, and the shell won't start: ```[error 0x8007010b when launching `powershell.exe'] Could not access starting directory "C:\Users\UserName\AppData\Local\Microsoft\WindowsApps\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\~"``` Setting the Startup directory to the parent process directory, or to `%USERPROFILE%` fixes the issue (and I still get put into my home directory, thanks to the commandline value). But immediately exiting seems like a terrible way for the terminal to handle not finding a directory. It should at least default to the parent process directory, I think.
Author
Owner

@DHowett commented on GitHub (May 27, 2021):

I had set the starting directory for both Ubuntu and Powershell to the value ~

This has never worked the way you're expecting. But, oh crap -- @zadjii-msft when we removed starting directory validation we also removed the magic fallback that substituted in USERPROFILE when it failed. I think this is good and correct, but it likely does account for a few of the on-launch "crashes" we've been seeing.

@DHowett commented on GitHub (May 27, 2021): > I had set the starting directory for both Ubuntu and Powershell to the value `~` This has never worked the way you're expecting. But, oh _crap_ -- @zadjii-msft when we removed starting directory validation we also removed the magic fallback that substituted in `USERPROFILE` when it failed. I think this is good and correct, but it likely does account for a few of the on-launch "crashes" we've been seeing.
Author
Owner

@DHowett commented on GitHub (May 27, 2021):

You can also just remove the startingDirectory. It didn't exist to begin with, and it eventually got an invalid value put into it.

That value will cease being invalid once #9223 lands.

@DHowett commented on GitHub (May 27, 2021): You can also just _remove_ the `startingDirectory`. It didn't exist to begin with, and it eventually got an invalid value put into it. That value will cease being invalid once #9223 lands.
Author
Owner

@JoBrad commented on GitHub (May 28, 2021):

@DHowett To clarify, when I said "since this works in either shell" I meant that the command cd ~ works in Powershell Core and in Ubuntu, therefore wsl ~ -d <distro> is a good workaround for startingDirectory failing to parse it.

You can also just remove the startingDirectory.

If you clear the value in the settings UI, it's replaced with %USERPROFILE%, which is OK. I just wish it used the distro-specific user profile directory (e.g. ~ and #9223 ) 😀

@JoBrad commented on GitHub (May 28, 2021): @DHowett To clarify, when I said "since this works in either shell" I meant that the command `cd ~` works in Powershell Core and in Ubuntu, therefore `wsl ~ -d <distro>` is a good workaround for startingDirectory failing to parse it. > You can also just remove the startingDirectory. If you clear the value in the settings UI, it's replaced with `%USERPROFILE%`, which is OK. I just wish it used the distro-specific user profile directory (e.g. `~` and #9223 ) 😀
Author
Owner

@DHowett commented on GitHub (May 28, 2021):

Definitely, that all makes sense.

9223 is going to be really cool once we can validate it. It makes us completely ignore startingDirectory for WSL and pass it in as an argument (ala wsl ~) except that it also supports crazy stuff like /etc and /mnt/c.

In short, this will finally work:

{
	"commandline": "wsl",
	"startingDirectory": "/var/lib/samba"
}
@DHowett commented on GitHub (May 28, 2021): Definitely, that all makes sense. 9223 is going to be really cool once we can validate it. It makes us completely ignore `startingDirectory` for WSL and pass it in as an argument (ala `wsl ~`) _except that it also supports crazy stuff like `/etc` and `/mnt/c`_. In short, this will finally work: ``` { "commandline": "wsl", "startingDirectory": "/var/lib/samba" } ```
Author
Owner

@Yangly0 commented on GitHub (Jun 1, 2021):

I met the same problem that it does not have access to "..\dir%Workspaces%".That's ok, and I just modify "%Workspaces%" to "/".

@Yangly0 commented on GitHub (Jun 1, 2021): I met the same problem that it does not have access to "..\dir\%Workspaces%".That's ok, and I just modify "%Workspaces%" to "/".
Author
Owner

@ghost commented on GitHub (Jul 14, 2021):

:tada:This issue was addressed in #10263, which has now been successfully released as Windows Terminal v1.9.1942.0.🎉

Handy links:

@ghost commented on GitHub (Jul 14, 2021): :tada:This issue was addressed in #10263, which has now been successfully released as `Windows Terminal v1.9.1942.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.9.1942.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Author
Owner

@ghost commented on GitHub (Jul 14, 2021):

:tada:This issue was addressed in #10263, which has now been successfully released as Windows Terminal Preview v1.10.1933.0.🎉

Handy links:

@ghost commented on GitHub (Jul 14, 2021): :tada:This issue was addressed in #10263, which has now been successfully released as `Windows Terminal Preview v1.10.1933.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.10.1933.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#13967