OSC 9;9 not working in WSL 2/Ubuntu? #17335

Closed
opened 2026-01-31 05:39:30 +00:00 by claunia · 8 comments
Owner

Originally created by @dallonf on GitHub (Apr 25, 2022).

Windows Terminal version

1.12.10982.0

Windows build number

10.0.19044.0

Other Software

WSL 2, Ubuntu 20.04.4

Steps to reproduce

  1. Add to .bashrc, as instructed by the documentation:
PROMPT_COMMAND=${PROMPT_COMMAND:+"$PROMPT_COMMAND; "}'printf "\e]9;9;%s\e\\" "$(wslpath -w "$PWD")"'
  1. cd into a directory other than home directory

  2. Right-click the terminal tab and select "Duplicate Tab"

Expected Behavior

I would expect the new tab to open in the directory I navigated to in step 2.
Failing that, I would love to have some tools to troubleshoot what's going on. What does it think the current directory is?

Actual Behavior

The new tab opens in the home directory, as if I had created a brand new tab, seemingly completely ignoring the current directory.

As much as I hate to open a "it doesn't work" issue, I really am at a loss for how to troubleshoot more.

Originally created by @dallonf on GitHub (Apr 25, 2022). ### Windows Terminal version 1.12.10982.0 ### Windows build number 10.0.19044.0 ### Other Software WSL 2, Ubuntu 20.04.4 ### Steps to reproduce 1. Add to `.bashrc`, as instructed by the [documentation](https://docs.microsoft.com/en-us/windows/terminal/tutorials/new-tab-same-directory#bash): ``` PROMPT_COMMAND=${PROMPT_COMMAND:+"$PROMPT_COMMAND; "}'printf "\e]9;9;%s\e\\" "$(wslpath -w "$PWD")"' ``` 2. `cd` into a directory other than home directory 3. Right-click the terminal tab and select "Duplicate Tab" ### Expected Behavior I would expect the new tab to open in the directory I navigated to in step 2. Failing that, I would love to have some tools to troubleshoot what's going on. What does it _think_ the current directory is? ### Actual Behavior The new tab opens in the home directory, as if I had created a brand new tab, seemingly completely ignoring the current directory. As much as I hate to open a "it doesn't work" issue, I really am at a loss for how to troubleshoot more.
claunia added the Issue-BugResolution-Duplicate labels 2026-01-31 05:39:30 +00:00
Author
Owner

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

Did you make sure to restart bash after adding that to your bashrc/? It's weird this isn't working for you, it definitely is locally 😕

You might be able to help troubleshoot using the debug tap. That'll get a trace of all the input and output from the terminal, including (hopefully) the OSC9;9 sequence. Send us a screenshot and we might be able to figure out what the Terminal thinks it's getting here.

@zadjii-msft commented on GitHub (Apr 28, 2022): Did you make sure to restart `bash` after adding that to your bashrc/? It's weird this isn't working for you, it definitely is locally 😕 You might be able to help troubleshoot using the [debug tap](https://github.com/microsoft/terminal/wiki/Enabling-the-debug-tap). That'll get a trace of all the input and output from the terminal, including (hopefully) the OSC9;9 sequence. Send us a screenshot and we might be able to figure out what the Terminal thinks it's getting here.
Author
Owner

@dallonf commented on GitHub (Apr 28, 2022):

Thanks for the response and instructions to find more info. I have definitely restarted bash several times - it was actually weeks ago I first noticed the issue, and only just now had time to report it.

Here's the debug tap of opening the terminal and cding into my devroot directory. At this point, I would expect duplicating a tab to go into the same directory, but it goes back home.

image

␛[?9001h␛[2J␛[m␛[H␛]0;Ubuntu␇␛[?25h␛[?25lTo␣run␣a␣command␣as␣administrator␣(user␣"root"),␣use␣"sudo␣<command>".␍␊See␣"man␣sudo_root"␣for␣details.␛[5;1H␛[?25h␛]9;9;\\wsl$\Ubuntu\home\dallonf␛\␛[32m␛[1mdallonf@Theseus-Desktop␛[m:␛[34m␛[1m~␛[m$␣␛]0;dallonf@Theseus-Desktop:␣~␇␛[67;46;99;1;0;1_␛[67;46;99;0;0;1_c␛[68;32;100;1;0;1_␛[68;32;100;0;0;1_d␛[32;57;32;1;0;1_␛[32;57;32;0;0;1_␣␛[68;32;100;1;0;1_␛[68;32;100;0;0;1_d␛[69;18;101;1;0;1_␛[69;18;101;0;0;1_e␛[86;47;118;1;0;1_␛[86;47;118;0;0;1_v␛[82;19;114;1;0;1_␛[82;19;114;0;0;1_r␛[9;15;9;1;0;1_oot/␛[9;15;9;0;0;1_␛[13;28;13;1;0;1_␛[13;28;13;0;0;1_␍␊␛]9;9;\\wsl$\Ubuntu\home\dallonf\devroot␛\␛[32m␛[1mdallonf@Theseus-Desktop␛[m:␛[34m␛[1m~/devroot␛[m$␣␛]0;dallonf@Theseus-Desktop:␣~/devroot␇
@dallonf commented on GitHub (Apr 28, 2022): Thanks for the response and instructions to find more info. I have definitely restarted bash several times - it was actually weeks ago I first noticed the issue, and only just now had time to report it. Here's the debug tap of opening the terminal and `cd`ing into my `devroot` directory. At this point, I would expect duplicating a tab to go into the same directory, but it goes back home. ![image](https://user-images.githubusercontent.com/346300/165746190-6127a46f-74cd-4724-8781-4b83c60d4d45.png) ``` ␛[?9001h␛[2J␛[m␛[H␛]0;Ubuntu␇␛[?25h␛[?25lTo␣run␣a␣command␣as␣administrator␣(user␣"root"),␣use␣"sudo␣<command>".␍␊See␣"man␣sudo_root"␣for␣details.␛[5;1H␛[?25h␛]9;9;\\wsl$\Ubuntu\home\dallonf␛\␛[32m␛[1mdallonf@Theseus-Desktop␛[m:␛[34m␛[1m~␛[m$␣␛]0;dallonf@Theseus-Desktop:␣~␇␛[67;46;99;1;0;1_␛[67;46;99;0;0;1_c␛[68;32;100;1;0;1_␛[68;32;100;0;0;1_d␛[32;57;32;1;0;1_␛[32;57;32;0;0;1_␣␛[68;32;100;1;0;1_␛[68;32;100;0;0;1_d␛[69;18;101;1;0;1_␛[69;18;101;0;0;1_e␛[86;47;118;1;0;1_␛[86;47;118;0;0;1_v␛[82;19;114;1;0;1_␛[82;19;114;0;0;1_r␛[9;15;9;1;0;1_oot/␛[9;15;9;0;0;1_␛[13;28;13;1;0;1_␛[13;28;13;0;0;1_␍␊␛]9;9;\\wsl$\Ubuntu\home\dallonf\devroot␛\␛[32m␛[1mdallonf@Theseus-Desktop␛[m:␛[34m␛[1m~/devroot␛[m$␣␛]0;dallonf@Theseus-Desktop:␣~/devroot␇ ```
Author
Owner

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

Okay this might sound dumb, but what does running

wsl --cd \\wsl$\Ubuntu\home\dallonf\devroot

from the run dialog (win+r) get you/?

@zadjii-msft commented on GitHub (Apr 28, 2022): Okay this might sound dumb, but what does running ``` wsl --cd \\wsl$\Ubuntu\home\dallonf\devroot ``` from the run dialog (`win+r`) get you/?
Author
Owner

@dallonf commented on GitHub (Apr 28, 2022):

Interesting question! That opens a shell (not Windows Terminal) of Ubuntu in the devroot directory - which I believe is expected behavior.

@dallonf commented on GitHub (Apr 28, 2022): Interesting question! That opens a shell (not Windows Terminal) of Ubuntu in the `devroot` directory - which I believe is expected behavior.
Author
Owner

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

There was something else recently about starting WSL.exe in WSL paths that was weird. IIRC it was an OS-side bug in WSL.exe, lemme see if I can't dig that one up. That might explain what we're seeing here...

@zadjii-msft commented on GitHub (Apr 28, 2022): There was something else recently about starting WSL.exe in WSL paths that was weird. IIRC it was an OS-side bug in WSL.exe, lemme see if I can't dig that one up. That might explain what we're seeing here...
Author
Owner

@dallonf commented on GitHub (May 18, 2022):

Found a workaround, thanks to this comment: https://github.com/microsoft/terminal/issues/3158#issuecomment-1129340025

Using a profile that targets wsl.exe -d Ubuntu seems to work properly, while a profile that targets Ubuntu.exe has the behavior I described in this issue (for lack of a better summary, "not working").

@dallonf commented on GitHub (May 18, 2022): Found a workaround, thanks to this comment: https://github.com/microsoft/terminal/issues/3158#issuecomment-1129340025 Using a profile that targets `wsl.exe -d Ubuntu` seems to work properly, while a profile that targets `Ubuntu.exe` has the behavior I described in this issue (for lack of a better summary, "not working").
Author
Owner

@zadjii-msft commented on GitHub (Aug 1, 2022):

Oh you know what, I know what this is. This is that thing going around where ubuntu.exe just ignores the startingDirectory, including via duplicating the CWD. I'm pretty sure we're tracking this in /dup #12961. Sorry about that!

@zadjii-msft commented on GitHub (Aug 1, 2022): Oh you know what, I know what this is. This is that thing going around where `ubuntu.exe` just ignores the `startingDirectory`, including via duplicating the CWD. I'm pretty sure we're tracking this in /dup #12961. Sorry about that!
Author
Owner

@ghost commented on GitHub (Aug 1, 2022):

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!

@ghost commented on GitHub (Aug 1, 2022): 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!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17335