Entering python's virtual environment results in all the letters to be changed into gibberish #15329

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

Originally created by @ashrasmun on GitHub (Sep 23, 2021).

Windows Terminal version (or Windows build number)

10.0.19043.1237

Other Software

WSL 2.0
Ubuntu-20.04

Steps to reproduce

  1. Add this line to your .bashrc:
    export PS1="[\e[1;30m]\w[\e[0m] > "
    That's my modified prompt, which should just show the path in gray.

  2. Make sure you are on Windows and not inside WSL. Create python's virtual environment on your hard drive (virtualenv).

  3. Enter WSL and activate the virtual environment using command env/Scripts/activate, not env/bin/activate.

Expected Behavior

Entering virtual environment should make all the letters go berserk. Example of how it should look after entering virtual environment:
image

Actual Behavior

image
image
Right after sourcing the activate script, WSL changed all my letters into incomprehensible mess. In Command Prompt the issue persists even after quitting WSL.
image

In command prompt opened from outside Windows Terminal the problem is... different. I cannot input newlines and I'm writing from the beginning of the line. I can however exit WSL and access it again in the same session, which is cool.

I found out that ConEmu has the least problems, as the only problem is with the string inside parentheses, which should express the name of virtual environment i'm in. New lines work and even though it looks ugly, it's usable.

image

Originally created by @ashrasmun on GitHub (Sep 23, 2021). ### Windows Terminal version (or Windows build number) 10.0.19043.1237 ### Other Software WSL 2.0 Ubuntu-20.04 ### Steps to reproduce 1. Add this line to your `.bashrc`: export PS1="\[\e[1;30m\]\w\[\e[0m\] > " That's my modified prompt, which should just show the path in gray. 2. Make sure you are on Windows and not inside WSL. Create python's virtual environment on your hard drive (virtualenv). 3. Enter WSL and activate the virtual environment using command `env/Scripts/activate`, not `env/bin/activate`. ### Expected Behavior Entering virtual environment should make all the letters go berserk. Example of how it should look after entering virtual environment: ![image](https://user-images.githubusercontent.com/12000269/134557500-b52bab84-815c-485d-afe8-bf54a35f748f.png) ### Actual Behavior ![image](https://user-images.githubusercontent.com/12000269/134557555-09d41d1c-5021-47f0-aa9b-8a5a03eebcf3.png) ![image](https://user-images.githubusercontent.com/12000269/134557590-89d877ef-58c5-4930-b418-5258879a1731.png) Right after sourcing the activate script, WSL changed all my letters into incomprehensible mess. In Command Prompt the issue persists even after quitting WSL. ![image](https://user-images.githubusercontent.com/12000269/134557635-643ecd63-1d9b-4e99-a99b-82a7a82ede88.png) In command prompt opened from outside Windows Terminal the problem is... different. I cannot input newlines and I'm writing from the beginning of the line. I can however exit WSL and access it again in the same session, which is cool. I found out that ConEmu has the least problems, as the only problem is with the string inside parentheses, which should express the name of virtual environment i'm in. New lines work and even though it looks ugly, it's usable. ![image](https://user-images.githubusercontent.com/12000269/134557677-8f0f0139-6e97-4d5a-8899-8f0ce3f8d934.png)
Author
Owner

@ashrasmun commented on GitHub (Sep 23, 2021):

Related thread: https://github.com/microsoft/WSL/issues/7440

@ashrasmun commented on GitHub (Sep 23, 2021): Related thread: https://github.com/microsoft/WSL/issues/7440
Author
Owner

@zadjii-msft commented on GitHub (Sep 23, 2021):

Without investigating too deep, this looks like the output from the virtual environment is in wide chars and WSL is expecting utf-8, or vice-versa. I'd suspect that the Windows virtualenvs aren't set up right to be used seamlessly with WSL, though I'm not seeing anything here https://github.com/pypa/virtualenv/issues?q=is%3Aissue+wsl+ that stands out

@zadjii-msft commented on GitHub (Sep 23, 2021): Without investigating too deep, this looks like the output from the virtual environment is in wide chars and WSL is expecting utf-8, or vice-versa. I'd suspect that the Windows virtualenvs aren't set up right to be used seamlessly with WSL, though I'm not seeing anything here https://github.com/pypa/virtualenv/issues?q=is%3Aissue+wsl+ that stands out
Author
Owner

@zadjii-msft commented on GitHub (Nov 1, 2021):

This looks highly similar to #10408. @ashrasmun does a reset work once the Terminal gets in that state? If so, then I'd reckon it's a dup.

@zadjii-msft commented on GitHub (Nov 1, 2021): This looks highly similar to #10408. @ashrasmun does a `reset` work once the Terminal gets in that state? If so, then I'd reckon it's a dup.
Author
Owner

@ghost commented on GitHub (Nov 5, 2021):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost commented on GitHub (Nov 5, 2021): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
Author
Owner

@ashrasmun commented on GitHub (Nov 6, 2021):

@zadjii-msft I don't think that works. This is me typing reset and pressing Enter:
image
and the problem is still there.

I don't know how much of an issue this is, given that technically I should be using linux virtual environment anyway.

@ashrasmun commented on GitHub (Nov 6, 2021): @zadjii-msft I don't think that works. This is me typing reset and pressing Enter: ![image](https://user-images.githubusercontent.com/12000269/140617083-a3ad8701-a1e0-42b5-979f-bba1cdd27620.png) and the problem is still there. I don't know how much of an issue this is, given that technically I should be using linux virtual environment anyway.
Author
Owner

@j4james commented on GitHub (Nov 6, 2021):

@ashrasmun Note that this part here:
¯íîô¯ã¯èïíå¯äåä¯ðòïêåãôó¯ðìïô ¾ òåóåô

Is just your path prompt and the reset command:
/mnt/c/home/ded/projects/plot > reset

Once you pressed enter I would have expected something more to be following that, even if it was still gibberish. If it's not actually resetting anything, there might still be an error message that tells us something.

Also, if you could cut and paste the actual characters you're seeing (rather than taking a screenshot) that would make it a little easier to decode.

@j4james commented on GitHub (Nov 6, 2021): @ashrasmun Note that this part here: `¯íîô¯ã¯èïíå¯äåä¯ðòïêåãôó¯ðìïô ¾ òåóåô` Is just your path prompt and the reset command: `/mnt/c/home/ded/projects/plot > reset` Once you pressed enter I would have expected something more to be following that, even if it was still gibberish. If it's not actually resetting anything, there might still be an error message that tells us something. Also, if you could cut and paste the actual characters you're seeing (rather than taking a screenshot) that would make it a little easier to decode.
Author
Owner

@ashrasmun commented on GitHub (Nov 7, 2021):

@j4james
I'm sorry for sending only the screenshot. I agree that the text would be easier to decode... I don't know why I did that.

I sent just my path because well... when I invoke the reset, the prompt is reset and the only remaining line is then ¯íîô¯ã¯èïíå¯äåä¯ðòïêåãôó¯ðìïô ¾. There's no error, nothing. The terminal is reloaded, but the characters are still weird.

image

/mnt/c > cd ../../home/dev/projects/plot/
/mnt/c/home/dev/projects/plot > source env/Scripts/activate
(\localhost\C-7KDNEUUomeSun Nov 07ev\projects\plotö© ¯íîô¯ã¯èïíå¯äåö¯ðòïêåãôó¯ðìïô ¾ òåóåô

After pressing Enter:

image

(\localhost\C-7KDNEUUomeSun Nov 07ev\projects\plotö© ¯íîô¯ã¯èïíå¯äåö¯ðòïêåãôó¯ðìïô ¾ 

@ashrasmun commented on GitHub (Nov 7, 2021): @j4james I'm sorry for sending only the screenshot. I agree that the text would be easier to decode... I don't know why I did that. I sent just my path because well... when I invoke the reset, the prompt is reset and the only remaining line is then `¯íîô¯ã¯èïíå¯äåä¯ðòïêåãôó¯ðìïô ¾`. There's no error, nothing. The terminal is reloaded, but the characters are still weird. ![image](https://user-images.githubusercontent.com/12000269/140635760-9e71cebe-781e-4948-b5b4-4ec3d11a5c4e.png) ``` /mnt/c > cd ../../home/dev/projects/plot/ /mnt/c/home/dev/projects/plot > source env/Scripts/activate (\localhost\C-7KDNEUUomeSun Nov 07ev\projects\plotö© ¯íîô¯ã¯èïíå¯äåö¯ðòïêåãôó¯ðìïô ¾ òåóåô ``` After pressing Enter: ![image](https://user-images.githubusercontent.com/12000269/140635766-84acb67f-93e5-42e6-9cc7-58e938ad5350.png) `(\localhost\C-7KDNEUUomeSun Nov 07ev\projects\plotö© ¯íîô¯ã¯èïíå¯äåö¯ðòïêåãôó¯ðìïô ¾ `
Author
Owner

@j4james commented on GitHub (Nov 7, 2021):

OK, thanks. That makes sense. I was convinced the reset hadn't actually run for some reason, so there would be an error message on the next line. I never considered that you wouldn't actually see anything if it had run. 🤦

Anyway that seems to rule out this being a dupe of #10408, but just to be sure, here are a couple of other things you can try. As with reset, just try executing these from the command line:

echo -e '\ec Test'

or

echo -e '\e[!p Test'

I'm hoping you might at least see the Test text displayed correctly, even if the prompt goes back to gibberish afterwards.

@j4james commented on GitHub (Nov 7, 2021): OK, thanks. That makes sense. I was convinced the reset hadn't actually run for some reason, so there would be an error message on the next line. I never considered that you wouldn't actually see anything if it had run. 🤦 Anyway that seems to rule out this being a dupe of #10408, but just to be sure, here are a couple of other things you can try. As with `reset`, just try executing these from the command line: ```echo -e '\ec Test'``` or ```echo -e '\e[!p Test'``` I'm hoping you might at least see the `Test` text displayed correctly, even if the prompt goes back to gibberish afterwards.
Author
Owner

@ashrasmun commented on GitHub (Nov 7, 2021):

Thanks for understanding 😊 Here are my results:

Attempting to echo -e '\ec Test'

image

/mnt/c/Users/ashra > cd ../../home/dev/projects/plot/
/mnt/c/home/dev/projects/plot > source env/Scripts/activate
(\localhost\C-7KDNEUUomeSun Nov 07ev\projects\plotö© ¯íîô¯ã¯èïíå¯äåö¯ðòïêåãôó¯ðìïô ¾ åãèï ­å §Üåã Ôåóô§

After "Enter":

image

 Test
(\localhost\C-7KDNEUUomeSun Nov 07ev\projects\plotö© ¯íîô¯ã¯èïíå¯äåö¯ðòïêåãôó¯ðìïô ¾ 

Attempting to echo -e '\e[!p Test'

image

 Test
(\localhost\C-7KDNEUUomeSun Nov 07ev\projects\plotö© ¯íîô¯ã¯èïíå¯äåö¯ðòïêåãôó¯ðìïô ¾ åãèï ­å §ÜåÛ¡ð Ôåóô§

After "Enter":

image

 Test
(\localhost\C-7KDNEUUomeSun Nov 07ev\projects\plotö© ¯íîô¯ã¯èïíå¯äåö¯ðòïêåãôó¯ðìïô ¾ åãèï ­å §ÜåÛ¡ð Ôåóô§
 Test
(\localhost\C-7KDNEUUomeSun Nov 07ev\projects\plotö© ¯íîô¯ã¯èïíå¯äåö¯ðòïêåãôó¯ðìïô ¾ 

If I start the second scenario from scratch I get the same result - printed Test and previous commands visible.

@ashrasmun commented on GitHub (Nov 7, 2021): Thanks for understanding 😊 Here are my results: Attempting to `echo -e '\ec Test'` ![image](https://user-images.githubusercontent.com/12000269/140643690-3f1c0438-6a1d-4473-ba16-a2283940c283.png) ``` /mnt/c/Users/ashra > cd ../../home/dev/projects/plot/ /mnt/c/home/dev/projects/plot > source env/Scripts/activate (\localhost\C-7KDNEUUomeSun Nov 07ev\projects\plotö© ¯íîô¯ã¯èïíå¯äåö¯ðòïêåãôó¯ðìïô ¾ åãèï ­å §Üåã Ôåóô§ ``` After "Enter": ![image](https://user-images.githubusercontent.com/12000269/140643721-1e3c438b-7ee9-4a0d-80d0-879833491999.png) ``` Test (\localhost\C-7KDNEUUomeSun Nov 07ev\projects\plotö© ¯íîô¯ã¯èïíå¯äåö¯ðòïêåãôó¯ðìïô ¾  ``` Attempting to `echo -e '\e[!p Test'` ![image](https://user-images.githubusercontent.com/12000269/140643815-108a5c70-13a7-42e1-9755-5800e4d936b3.png) ``` Test (\localhost\C-7KDNEUUomeSun Nov 07ev\projects\plotö© ¯íîô¯ã¯èïíå¯äåö¯ðòïêåãôó¯ðìïô ¾ åãèï ­å §ÜåÛ¡ð Ôåóô§ ``` After "Enter": ![image](https://user-images.githubusercontent.com/12000269/140643824-bc08bffa-a396-4883-a56a-6643bf1c13bf.png) ``` Test (\localhost\C-7KDNEUUomeSun Nov 07ev\projects\plotö© ¯íîô¯ã¯èïíå¯äåö¯ðòïêåãôó¯ðìïô ¾ åãèï ­å §ÜåÛ¡ð Ôåóô§ Test (\localhost\C-7KDNEUUomeSun Nov 07ev\projects\plotö© ¯íîô¯ã¯èïíå¯äåö¯ðòïêåãôó¯ðìïô ¾  ``` If I start the second scenario from scratch I get the same result - printed `Test` and previous commands visible.
Author
Owner

@j4james commented on GitHub (Nov 7, 2021):

This is good news I think. The resets are definitely working, but it looks like there's something in the prompt that is triggering the character set to change back. There's a good chance this will be fixed by PR #11658.

@j4james commented on GitHub (Nov 7, 2021): This is good news I think. The resets are definitely working, but it looks like there's something in the prompt that is triggering the character set to change back. There's a good chance this will be fixed by PR #11658.
Author
Owner

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

@ashrasmun Hey looping back on this - was this fixed in 1.12/?

@zadjii-msft commented on GitHub (Jun 14, 2022): @ashrasmun Hey looping back on this - was this fixed in 1.12/?
Author
Owner

@ghost commented on GitHub (Jun 18, 2022):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost commented on GitHub (Jun 18, 2022): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#15329