startingDirectory and high WSL CPU usage #16608

Closed
opened 2026-01-31 05:17:06 +00:00 by claunia · 12 comments
Owner

Originally created by @cmsavage on GitHub (Feb 3, 2022).

Windows Terminal version

1.12.3472

Windows build number

19043.1466

Other Software

WSL
Ubuntu-18.04 (WSL)

Steps to reproduce

Set startingDirectory to /home/username or //wsl$/Ubuntu-18.04/home/username (tried via settings UI).

Expected Behavior

WSL sessions start in desired directory.

Actual Behavior

WSL sessions do not start in desired directory and sessions use 100% CPU (shows as init process via htop and windows task manager).

This documentation page suggests using the above formats for the WSL startingDirectory; I seem to recall the //wsl$/Ubuntu-18.04/home/username format worked fine in the past. The starting directory is set properly without the high CPU usage if the slashes are changed to backslashes (\\wsl$\Ubuntu-18.04\home\username).

Solution discovered via this WSL2 issue.

WindowsTerminal_WSL_HighCPU_anon

Originally created by @cmsavage on GitHub (Feb 3, 2022). ### Windows Terminal version 1.12.3472 ### Windows build number 19043.1466 ### Other Software WSL Ubuntu-18.04 (WSL) ### Steps to reproduce Set `startingDirectory` to `/home/username` or `//wsl$/Ubuntu-18.04/home/username` (tried via settings UI). ### Expected Behavior WSL sessions start in desired directory. ### Actual Behavior WSL sessions do not start in desired directory and sessions use 100% CPU (shows as `init` process via `htop` and windows task manager). [This documentation page](https://docs.microsoft.com/en-us/windows/terminal/troubleshooting#set-your-wsl-distribution-to-start-in-the-home--directory-when-launched) suggests using the above formats for the WSL startingDirectory; I seem to recall the `//wsl$/Ubuntu-18.04/home/username` format worked fine in the past. The starting directory is set properly without the high CPU usage if the slashes are changed to backslashes (`\\wsl$\Ubuntu-18.04\home\username`). Solution discovered via [this WSL2 issue](https://github.com/microsoft/WSL/issues/5285#issuecomment-1008750607). ![WindowsTerminal_WSL_HighCPU_anon](https://user-images.githubusercontent.com/3375005/152368917-1df11c60-dc00-495c-a86f-100d2c2d2a58.png)
Author
Owner

@cmsavage commented on GitHub (Feb 3, 2022):

For anyone experiencing the high CPU issue, a workaround is to use backslashes instead of slashes in startingDirectory.

If you use the "open windows from previous session" as your Windows Terminal startup mode, old sessions from prior to changing the starting directory will continue to experience this issue. Sessions created after changing the starting directory will work correctly during later Windows Terminal startups.

@cmsavage commented on GitHub (Feb 3, 2022): For anyone experiencing the high CPU issue, a workaround is to use backslashes instead of slashes in `startingDirectory`. If you use the "open windows from previous session" as your Windows Terminal startup mode, old sessions from prior to changing the starting directory will continue to experience this issue. Sessions created after changing the starting directory will work correctly during later Windows Terminal startups.
Author
Owner

@zadjii-msft commented on GitHub (Feb 9, 2022):

@cmsavage does this issue repro for you on 1.13? There are some fixes in this area in 1.13, and I'm wondering if they might help sort this out too. Might be worth backporting them.

@zadjii-msft commented on GitHub (Feb 9, 2022): @cmsavage does this issue repro for you on 1.13? There are some fixes in this area in [1.13](https://github.com/microsoft/terminal/releases/tag/v1.13.10336.0), and I'm wondering if they might help sort this out too. Might be worth backporting them.
Author
Owner

@cmsavage commented on GitHub (Feb 9, 2022):

The long form (//wsl$/Ubuntu-18.04/home/username) works in 1.13 with slashes or backslashes. However, the "linux style paths" that are supposed to be acceptable since 1.12 do not work either way: ubuntu fails to start with \home\username ("The parameter is incorrect") and the high CPU usage still occurs with /home/username, though I do end up in the correct directory in that case. So some improvement in 1.13, but not fully working for all the path formats the documentation claims it should.

@cmsavage commented on GitHub (Feb 9, 2022): The long form (`//wsl$/Ubuntu-18.04/home/username`) works in 1.13 with slashes or backslashes. However, the "linux style paths" that are supposed to be acceptable since 1.12 do not work either way: ubuntu fails to start with `\home\username` ("The parameter is incorrect") and the high CPU usage still occurs with `/home/username`, though I do end up in the correct directory in that case. So some improvement in 1.13, but not fully working for all the path formats the documentation claims it should.
Author
Owner

@zadjii-msft commented on GitHub (Feb 9, 2022):

@craigloewen-msft / @benhillis any idea what this might be?

@zadjii-msft commented on GitHub (Feb 9, 2022): @craigloewen-msft / @benhillis any idea what this might be?
Author
Owner

@maknapp commented on GitHub (Mar 15, 2022):

I am on Windows Terminal v1.11.3471 and I had my starting directory set to /mnt/c/myfolder and was getting high CPU usage on init process. I switched to C:\myfolder and no longer have high CPU usage. (Both /mnt/c/myfolder and C:\myfolder values worked and started up to the correct directory.)

@maknapp commented on GitHub (Mar 15, 2022): I am on Windows Terminal v1.11.3471 and I had my starting directory set to `/mnt/c/myfolder` and was getting high CPU usage on `init` process. I switched to `C:\myfolder` and no longer have high CPU usage. (Both `/mnt/c/myfolder` and `C:\myfolder` values worked and started up to the correct directory.)
Author
Owner

@calexandre commented on GitHub (Mar 16, 2022):

I confirm the same issue using the Windows Terminal 1.11.3471.0.
As a workaround I temporarily removed the startingDirectory setting and then tweaked the .zshrc / .bashrc file to jump into the home dir... Something like this: cd ~

EDIT:
This method also works and its cleaner: "startingDirectory": "\\\\wsl$\\Ubuntu\\home\\username"

Hope it helps someone...

@calexandre commented on GitHub (Mar 16, 2022): I confirm the same issue using the Windows Terminal `1.11.3471.0`. As a workaround I temporarily removed the `startingDirectory` setting and then tweaked the `.zshrc / .bashrc` file to jump into the home dir... Something like this: `cd ~` EDIT: This method also works and its cleaner: `"startingDirectory": "\\\\wsl$\\Ubuntu\\home\\username"` Hope it helps someone...
Author
Owner

@ccfontes commented on GitHub (Mar 17, 2022):

This method also works and its cleaner: "startingDirectory": "\\wsl$\Ubuntu\home\username"

Nice, this works for me! Thanks. 🥳

WT 1.13.10395.0

@ccfontes commented on GitHub (Mar 17, 2022): > This method also works and its cleaner: "startingDirectory": "\\\\wsl$\\Ubuntu\\home\\username" Nice, this works for me! Thanks. 🥳 WT 1.13.10395.0
Author
Owner

@zadjii-msft commented on GitHub (Mar 22, 2022):

This is tracked by MSFT:38630955 internally.

@zadjii-msft commented on GitHub (Mar 22, 2022): This is tracked by MSFT:38630955 internally.
Author
Owner

@ghost commented on GitHub (Apr 5, 2022):

@cmsavage If you can still reproduce this bug, would you mind sharing a screenshot of the Terminal process in Task Manager with the WSL process showing and with the CommandLine attribute visible like below? Thanks!

image
@ghost commented on GitHub (Apr 5, 2022): @cmsavage If you can still reproduce this bug, would you mind sharing a screenshot of the Terminal process in Task Manager with the WSL process showing and with the CommandLine attribute visible like below? Thanks! <img width="506" alt="image" src="https://user-images.githubusercontent.com/87386551/161853560-d9a031e4-a1c8-411e-bba5-8af510e022ec.png">
Author
Owner

@cmsavage commented on GitHub (Apr 6, 2022):

I cannot seem to attach an image at the moment, but here are the command lines (Windows Terminal Preview 1.13.10733.0).

  • When setting the starting directory to /home/username, which leads to the high CPU usage:
    "C:\WINDOWS\system32\wsl.exe" --cd "/home/username" -d Ubuntu-18.04
  • When setting the starting directory to //wsl$/Ubuntu-18.04/home/username, which works correctly:
    "C:\WINDOWS\system32\wsl.exe" --cd "\\wsl$\Ubuntu-18.04\home\username" -d Ubuntu-18.04

BTW, the ability to copy info from the task manager is a feature I never knew I wanted, but does not exist. :(

@cmsavage commented on GitHub (Apr 6, 2022): I cannot seem to attach an image at the moment, but here are the command lines (Windows Terminal Preview 1.13.10733.0). - When setting the starting directory to `/home/username`, which leads to the high CPU usage: `"C:\WINDOWS\system32\wsl.exe" --cd "/home/username" -d Ubuntu-18.04` - When setting the starting directory to `//wsl$/Ubuntu-18.04/home/username`, which works correctly: `"C:\WINDOWS\system32\wsl.exe" --cd "\\wsl$\Ubuntu-18.04\home\username" -d Ubuntu-18.04` BTW, the ability to copy info from the task manager is a feature I never knew I wanted, but does not exist. :(
Author
Owner

@cmsavage commented on GitHub (Apr 6, 2022):

For anyone coming across this thread and just looking to drop into your home directory on new sessions, the default starting directory in Preview 1.13 (~) seems to work fine without the high CPU usage. I am not sure when that became a working option (new feature?). That is much cleaner than providing an explicit directory.

The documentation could use an update once these features move into the mainline version from WT Preview.

@cmsavage commented on GitHub (Apr 6, 2022): For anyone coming across this thread and just looking to drop into your home directory on new sessions, the default starting directory in Preview 1.13 (`~`) seems to work fine without the high CPU usage. I am not sure when that became a working option (new feature?). That is much cleaner than providing an explicit directory. The [documentation](https://docs.microsoft.com/en-us/windows/terminal/troubleshooting#set-your-wsl-distribution-to-start-in-the-home--directory-when-launched) could use an update once these features move into the mainline version from WT Preview.
Author
Owner

@zadjii-msft commented on GitHub (Apr 14, 2022):

Welp. Seems like this is resolved then. Glad it went away!

@zadjii-msft commented on GitHub (Apr 14, 2022): Welp. Seems like this is resolved then. Glad it went away!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#16608