WSL: Could not access starting directory \\wsl$\Ubuntu\home error 0x8007010b

Windows Build Number

Version 10.0.19041.985

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.4.72

Distro Version

20.04

Other Software

Visual Studio Code 1.51.1 connected to Ubuntu

Repro Steps

opening ubuntu on windows terminal preview

Expected Behavior

access to wsl

Actual Behavior

[error 0x8007010b when launching `wsl.exe -d Ubuntu’] Could not access starting directory “//wsl$/Ubuntu/home/SAGRI”

Diagnostic Logs

No response

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 56
  • Comments: 141 (19 by maintainers)

Commits related to this issue

Most upvoted comments

I was able to solve this by going into the windows terminal settings, going to the ubuntu profile, and ticking the “Use parent process directory” box. No idea why that worked. It’s also worth noting that this occurred to me right after a reboot.

I had the same problem. It seems that the directory path notation has changed from slash to backslash. Before: //wsl$/linux-distro/home/user After: \\wsl$\linux-distro\home\user

I ticked “Use parent process directory” but left command line as wsl.exe ~ -d Debian and no further changes were required.

Thanks for the info

I was able to solve this by going into the windows terminal settings, going to the ubuntu profile, and ticking the “Use parent process directory” box. No idea why that worked. It’s also worth noting that this occurred to me right after a reboot.

Perfect, just had the same issue and the above worked for me - either run in cmd prompt or tick the above setting. Lifesaver!!

I have several WSL distributions, need to tick this for all of them if using Windows Terminal. Must have been some sneaky stealth update last night?

Edit again: This seems to happen if you have a custom startup directory - I did since I don’t want to start my Linux in the windows %USERPROFILE% every time. However, If I tick the box, then untick and set the “\\wsl$\Ubuntu\blahblah\home” path to my home directory manually again it all works as before, and I start up in the correct (Linux) home dir.

Just to reiterate, I was having the same issue. This is specific to terminal right now. Running just wsl.exe on powershell works fine and ticking the “Use parent process directory” box in terminal settings seems to have fixed it for me too.

You’re right @swebs ! My apologies for the comment above and closing this issue out early, I just had a quick call with @DHowett and I can add some clarity here:

This error can be caused by two things: An incorrectly formatted starting-directory format, or if the path that starting-directory is querying fails. The latter could happen when you’re using \\wsl$\ in your starting-directory value as there seems to be an intermittent bug where querying \\wsl$\ paths sometimes fails.

This behaviour has only shown up now as the ‘on starting directory error’ behaviour in Windows Terminal changed in version 1.8. In that version it now fails on start up if the starting-directory fails, rather than putting you in your %USERPROFILE% directory which caused inconsistent start up locations.

On the WSL team we’ll look into \\wsl$\ queries failing (and I’ll reopen this issue to track that). In the meantime if you’re seeing this a lot I would recommend using wsl.exe ~ in your command line in Windows Terminal to start up in your home directory in Linux, or if you are on the latest Insider builds you can use wsl.exe --cd <Directory> to start up in specific paths (check usage with wsl --help). Thanks!

Edit again: This seems to happen if you have a custom startup directory - I did since I don’t want to start my Linux in the windows %USERPROFILE% every time. However, If I tick the box, then untick and set the “\wsl$\Ubuntu\blahblah\home” path to my home directory manually again it all works as before, and I start up in the correct (Linux) home dir.

Thanks. This worked for me.

I added a few lines to my .zshrc/.bashrc that references my %USERPROFILE% variable. If we end up there, navigate to where we want the default to be instead. Replace ~ with your desired start directory.

if [[ $(pwd) == /mnt/c/Users/mostlikely-your-pc-name ]]
then
    cd ~
fi

The Windows Terminal starts without an issue after I have changed the Windows Terminal settings, the Starting directory from ‘//wsl$/Ubuntu-20.04/home/<user name>/’ to ‘/home/<user name>/’

Windows 11 Pro for Workstations, version 21H2, build 22000.282 Windows Terminal version 1.11.2921.0

@craigloewen-msft I don’t think this should be closed. As far as I know, everyone on this thread has a correctly specified starting-directory it just doesn’t work anymore in Windows Terminal Preview until after you start wsl once via some other means after a reboot. My starting-directory is \\wsl$\Debian\home\swebs for example and I have this problem.

I had the same issue, ticking “Use parent process directory” indeed fixes the described error but starts my shell in /mnt/c/WINDOWS/system32 which I don’t like. Manually setting it to:

//wsl$/Ubuntu-20.04/home/linuxUsername

Sets the start dir to my Linux user’s home dir ~/ as it should be.

I did a browse in windows explorer to see if something changed in the path, and on my machine it looks like the //wsl$ has changed to \\wsl.localhost. So updating my default directory to \\wsl.localhost\Ubuntu-18.04\home\dylan fixed it in this case.

It seems like sometimes leaving it as //wsl$ works though if you kill wsl.exe and restart it. So I’m not sure what the convention is supposed to be, or if it’s just buggy.

The problem seems to be that Windows Terminal is looking for the startup directory while wsl.exe hasn’t even started, hence it can’t open the startup directory.

I had the same problem but changing my startingDirectory to backslashes did not fix it.

This will not work if WSL is not already running:

                "startingDirectory": "\\\\wsl$\\Ubuntu\\home\\alan"

So for the time being, as suggested, I commented that out and added this, which worked:

                "commandline": "wsl.exe ~"

I noticed that the \\wsl$\Ubuntu mountpoint did not exist until the WSL OS was already “Running”. I guess this is why Windows Terminal considers it an invalid path, though I don’t totally understand why it was working until now.

I found a solution that works well

  • Go into terminal settings
  • Don’t worry about the starting directory
  • In “Command Line” add a ~ after the .exe

For example:

wsl.exe -d Ubuntu -> wsl.exe ~ -d Ubuntu

It will open into the $HOME directory of the distro (Ubuntu in my example). Found that it works even if setting the terminal to run on boot (which some of the other solutions didn’t) and it is cleaner than setting things in .bashrc.

This error is related to your starting-directory setting in Windows Terminal. If the starting directory value is invalid, you’ll see this error.

If you’d like to start up in WSL paths please use \\wsl$\ to do that. For example to start in my home directory in Linux I set my starting directory to be \\wsl$\home\caloewen\ or I could set my command line for my WSL profile to be wsl.exe ~.

I’ll close this issue out as it’s an expected behaviour.

We are getting a lot of workarounds in this thread, and a lot of people reporting it working or not working under certain circumstances.

Can’t someone from Microsoft just fix the problem? From the sheer volume of messages, it is obviously an issue that affects a lot of people, just put some developers on it, and get it sorted.

Or at least tell us you are working on it and tell us why it is so hard to fix.

I installed Ubuntu as the host OS instead of windows, means I don’t have to worry about the problem any more.

On Mon, 3 Apr 2023, 10:32 ligang, @.***> wrote:

I had the same problem. It seems that the directory path notation has changed from slash to backslash. Before: //wsl$/linux-distro/home/user After: \wsl$\linux-distro\home\user

I also encountered the same problem. How did you finally solve it?

— Reply to this email directly, view it on GitHub https://github.com/microsoft/WSL/issues/6995#issuecomment-1493991804, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA4SWMQZBLI3BUVV6ISQVLW7KKLDANCNFSM45SJMOSQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

The Windows Terminal starts without an issue after I have changed the Windows Terminal settings, the Starting directory from ‘//wsl$/Ubuntu-20.04/home/<user name>/’ to ‘/home/<user name>/’

Windows 11 Pro for Workstations, version 21H2, build 22000.282 Windows Terminal version 1.11.2921.0

Thank you

No one seems to understand, or care, why it happens.

On Fri, 8 Oct 2021, 09:28 cwl12315, @.***> wrote:

I also have the same problem. I don‘t change the terminal configuration, but manually started the LxssManagerUser_xxxx service in the task manager, and then it was normal. I don’t understand why this happens.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/microsoft/WSL/issues/6995#issuecomment-938448818, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA4SWKXF7IXOC6SU7RQ773UF2TSPANCNFSM45SJMOSQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

That’s breaking the “Open in Windows Terminal”-Rightclick Option on directories, since it’ll now always open in the homedir.

i found one way to change starting directory for Ubuntu. first open Json file in settings, and then add this line:


"commandline": "wsl.exe --cd C:/Users/yourProfile -d Ubuntu-22.04"

I did a browse in windows explorer to see if something changed in the path, and on my machine it looks like the //wsl$ has changed to \\wsl.localhost. So updating my default directory to \\wsl.localhost\Ubuntu-18.04\home\dylan fixed it in this case.

It seems like sometimes leaving it as //wsl$ works though if you kill wsl.exe and restart it. So I’m not sure what the convention is supposed to be, or if it’s just buggy.

For me changing starting directory to “\wsl.localhost\Ubuntu\home\User” worked in windows terminal.

Thanks for all the reports of the issue. We were able to get a local repro and are working on a fix.

Rebooted, followed the Feedback-Hub procedure and started the recording:

  • Opened the Windows Terminal
  • Error appeared
  • Opened a few new tabs. Each with the error.
  • Opened a PowerShell Tab, ran wsl --shutdown
  • Opened another Ubuntu Tab, it loaded for a while as WSL is starting up
  • Working Prompt

Feedback Link: https://aka.ms/AAdr3xc

Yeha, startup directory works till you actually want to access the non-wsl filesystem,

\\\\wsl$\\Ubuntu-22.04\\mnt works but \\\\wsl$\\Ubuntu-22.04\\mnt\\c causes it to crash with [process exited with code 4294967295 (0xffffffff)]

No suggestions actually seem to work here, or anywhere.

There are so many threads, and no one in any of them has a solid answer to how to change the startup directory. Just piles of “try this” changes that don’t actually work.

The docs should really be covering this.

@Kolobamanacas thanks again for pointing this one out; I fixed our documentation up in https://github.com/MicrosoftDocs/terminal/pull/623 😄

@darkvertex Alas, that’s one of the worst parts of this whole “working directory” thing. I wish we could restore remote working directories!

Had the same problem with the “Starting Directory”. Reason for it was that I was setting it on a profile which ran ubuntu2204.exe (no idea why this gets auto added when it’s buggy like this), but using the other profile which runs C:\WINDOWS\system32\wsl.exe -d Ubuntu-22.04 works just fine.

Same issue, Windows 11 Everything worked, until yesterday. It looks like the problem is related to the initialization of the paths. For example, in Total Commander I have a tab that opens the home folder: \wsl$\Ubuntu-18.04\home\qzya - it also does not work. If I remove the “Starting directory” in the WT settings, then wsl starts (with Windows directory as home). After that, you can set back “Starting directory” setting to \wsl$\Ubuntu-18.04\home\qzya and new windows of wsl will normally start with the correct start directory. A simple launch of File Explorer also helps. The tab in Total Commander also working after these manipulations. I also noticed that in File Explorer the path \wsl.localhost\Ubuntu-18.04 is now used to access the wsl directories, it seems to me, that the path \wsl$\Ubuntu-18.04 was always used before? I may be wrong. PS: however, the path \wsl$\ - also works, but in the side menu of File Explorer the Linux -> Ubuntu-18.04 item (this is a new item for Windows 11 as far as I remember) refers exactly to \wsl.localhost\Ubuntu-18.04

For me the solution that works is the one described by @BtbN - once WSL2 has been started outside of Windows Terminal everything seems to work fine. I’m using Windows Terminal 1.10.2383.0 on Windows 11 (10.0.22000)

That sounds like it’ll only work until next reboot. Once WSL is started up, the Terminal will be able to cd to the wsl$ starting dir just fine. I have now just put a script with wsl --shutdown into my startup scripts, which seems to reliably work around the issue for now.

Watching this. Same issue, the working StartingDirectory value (//wsl$/Ubuntu-20.04/root) was valid before updating to 1.8.

If I start WSL first, it works, so it seems Terminal is trying to open the path before WSL is started.

image

If \\wsl$ is failing, this is a WSL bug.

I ticked “Use parent process directory” but left command line as wsl.exe ~ -d Debian and no further changes were required.

Thanks for the info

Yeah, this worked for me!

I was able to solve this by going into the windows terminal settings, going to the ubuntu profile, and ticking the “Use parent process directory” box. No idea why that worked. It’s also worth noting that this occurred to me right after a reboot.

Worked for me, but it started me on System32. Went back into settings and unchecked “User parent process directory”. Loaded another tab and it is back to working normally as it did previously with the correct profile loaded.

@RollsChris , here is what worked for me:

in .zshrc:

precmd() {
  print -Pn "\e]9;9;$PWD\e\\"
}

In Windows Terminal settings, configured these attributes as:

{
    "commandline": "wsl.exe -d Debian",
    "startingDirectory": "~",
}

Happy to help! Let me make sure that we don’t have the version in our documentation that is busted. 😁

The giveaway here is that the path starts with Microsoft.PowerShell.Core\FileSystem::. That means it’s actually a powershell internal path!

In your OSC9;9 location report from your PS profile, you should actually use (...).CurrentLocation.ProviderPath. That will return the real on-disk path.

That seems unnecessarily complicated. You could also just change it to wsl.exe -d Ubuntu. Then the startingDirectory setting will work normally.

no idea why this gets auto added when it’s buggy like this

This is something that will need to be raised with Canonical! Their built-in profile json “fragment” tells us to add it.

Again, that’s not a good solution, since it will break the context menu option to open a terminal in that directory. It will always open in ~ then.

Hope this helps.

Windows Terminal profile can call wsl with options. In this case, what we need is to supply the --cd ~ option.

wsl.exe -d Ubuntu --cd ~

Same issue here, Windows 11.

I’ve solved it by changing my startingDirectory to "\\\\wsl$\\Ubuntu\\home\\mysy" in the json file. For some reason the solutions listed above didn’t help me.

I’m running into this issue too. Started happening after upgrading to Windows 11. If I start a new PowerShell terminal and run wsl, the issue goes away, but I need to do this every fresh boot.

Just running “wsl” or “wsl --shutdown” in a normal/ps terminal is much less of a headache and achieves the same goal of getting WSL started up so the starting dir can work.

Hi, I was facing the same problem and I tried almost every suggestion from this thread and relevant suggestions from https://github.com/microsoft/terminal/issues/2743.

Apparently, for me, the problem was due to the virtualization being reverted back to turned off due to a recent bios update that I did on my motherboard. So every time when I used to launch the terminal (after the bios update) I got this same error Could not access starting directory \wsl$\Ubuntu\home error 0x8007010b. From a separate Powershell, I tried running wsl.exe -d Ubuntu and saw this message

Screenshot 2021-09-15 150230

Then I checked the bios and found the virtualization was turned back to disabled. Once I set it back to enabled and restarted the pc the problem disappeared. I know this solution may not be applicable in all scenarios but for me, this is how the issue was solved.

The approach of @cggonzal works! (checking “use parent process directory”)

After that I tried changing the “Starting directory” to “\\wsl.localhost\Ubuntu\home\username” and this also worked for me. And now the terminal starts in my home directory again.

Old value was “\\wsl$\Ubuntu\home\username”

The shutdown can’t be a complete no-op. It’s doing something that’s enough for the //wsl$ startup path to start working.

It happens 100% consistently for me every fresh boot. I’ll see if I can get logs.

I’m having the exact same issue after every fresh boot. I then have to run wsl --shutdown , even though it’s not even started yet and it finishes instantly, and then it works.

So for the time being, as suggested, I commented that out and added this, which worked:

                "commandline": "wsl.exe ~"

I don’t know why this isn’t the default for WSL configuration to begin with… I also added the bashrc entry to cd ~ when the path was my windows profile.

I had the same problem. It seems that the directory path notation has changed from slash to backslash. Before: //wsl$/linux-distro/home/user After: \\wsl$\linux-distro\home\user

This one fixed it for me. Seems like a questionable choice to just change this without warning and without grandfathering the previous syntax in.

I can confirm that the problem also recurs for me when I reboot. This time I solved it by starting wsl from PowerShell in Terminal Preview (it started up in %USERPROFILE% rather than my custom location). Then I opened a wsl Terminal tab directly and it correctly opened in my custom location.

From my experience (also Windows Terminal Preview), it seems there was nothing wrong with my original settings, but I needed to delete the custom starting directory, successfully start my WSL instance, close it, then put back the same custom starting directory and it worked again.

I did too, but once I rebooted my PC the error appeared again.

I ticked “Use parent process directory” but left command line as wsl.exe ~ -d Debian and no further changes were required.

Thanks for the info

That’s very useful, I like this option, rather than setting the path manually. Hopefully the Windows Terminal will allow using linux shortcuts sometime?

Edit again: This seems to happen if you have a custom startup directory - I did since I don’t want to start my Linux in the windows %USERPROFILE% every time. However, If I tick the box, then untick and set the “\wsl$\Ubuntu\blahblah\home” path to my home directory manually again it all works as before, and I start up in the correct (Linux) home dir.

Thanks. This worked for me.

I added a few lines to my .zshrc/.bashrc that references my %USERPROFILE% variable. If we end up there, navigate to where we want the default to be instead. Replace ~ with your desired start directory.

if [[ $(pwd) == /mnt/c/Users/mostlikely-your-pc-name ]]
then
    cd ~
fi

This one works for me, better to start at home directory.

Just go to Windows Terminal>Settings>Ubuntu and replace the starting directory field with Z:\home\username (replace Z: with whatever drive your WSL is mapped on and username with the relevant username/folder name).