15

I'm having some problems using WSL.

If I run WSL as a normal user, the terminal will occasionally start to type by itself. Because of this, using WSL where any input is required (e.g. vi/vim, nano, etc.) is impossible.

Several examples:

  • I'm trying to change my password and then, some ^@^@^@^@ is typed on its own:

    gabriel@PC:~$ passwd
    Changing password for gabriel.
    Current password:
    ^@^@^@^@passwd: Authentication token manipulation error
    passwd: password unchanged
    gabriel@PC:~$
    
  • When using vi/vim, it quits the insertion mode or types on screen.

  • When using nano, it only type some newlines (i.e. \n).

If I start WSL as Admin, none of these problems occur.

Does anyone know why this is happening?

7
  • 5
    The ^@ symbol itself is a null character, so it probably doesn't show up anywhere else. I found a similar issue with WSL>powershell in windows terminal. It looks like the cause in that case is WSL doing some things in UTF16 that the terminal doesn't like. You could have some input encoding issue on your default user's profile (but not the admin)? github.com/microsoft/WSL/issues/6787 (and linked issues)
    – Cpt.Whale
    Commented Jul 13, 2022 at 13:41
  • @Cpt.Whale Interesting idea - I'm quite familiar with the UTF16 issue, but I can't see how that would cause the symptoms described in this question. Not ruling it out, though, since the null character issue is similar, at least. Commented Jul 13, 2022 at 14:10
  • @gabriel What terminal are you using (e.g. the default Windows legacy console, Windows Terminal, or another)? And what Windows version? Thanks! Commented Jul 13, 2022 at 14:12
  • @NotTheDr01ds I'm using Windows 11 and Windows Terminal. I tried to run WSL through powershell and CMD, the symptoms are the same on both Commented Jul 13, 2022 at 17:09
  • @GabrielJefferson Hmm - As an additional troubleshooting step, it might be worth trying to install a different distribution. What are you running now? Just wondering if it's something happening in WSL itself or in the particular instance/distribution. Commented Jul 13, 2022 at 17:39

1 Answer 1

22

After reading the issue commented by @Cpt.Whale and this doc from Microsoft (about_Character_Encoding)

My solution to the problem was:
Changing the default encoding value (see the link above)

$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
2
  • 4
    Excellent - Good to hear you got it resolved! I'm guessing there's some other "root cause" for this, since it's not normal to have to do this just to run normal WSL/Linux apps/distributions. If you happen to figure that part out at some point, remember to update the answer. Definitely upvoted for just the "workaround" alone, though. Also don't forget to come back in a couple of days to accept your answer (or check to see if someone has another alternative that you might want to accept) - Thanks! Commented Jul 13, 2022 at 19:30
  • 2
    Hey Gabriel, from your question it seems that starting a cmd shell, then starting wsl (presumably using the linux OS shell of bash or whatever), still caused the weird characters, even if powershell was never running(?) But this solution seems like it would only work in powershell? Maybe you can edit your question to clarify where you are running powershell, and which version (specifically, at v6 or below v6).
    – Carl Walsh
    Commented Jul 14, 2022 at 18:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .