unison icon indicating copy to clipboard operation
unison copied to clipboard

UCM on Windows gives strange prompt

Open meijeru opened this issue 2 years ago • 6 comments

I am running release/M4 of ucm.exe on Windows 11. The prompt is [0m[32m.[0m> [0m which seems to indicate a wrong interpretation of ANSI escape sequences by my terminal application (both Windows Console Host and Windows Terminal exhibit this behaviour). The multicolour ASCII art in the banner is displayed correctly, though.

meijeru avatar Jul 26 '22 17:07 meijeru

Additionally, but I don't know if it is strictly related, non-ASCII characters (e.g. emojis) are not displayed correctly. Instead, I see boxed question marks.

meijeru avatar Jul 26 '22 18:07 meijeru

https://github.com/judah/haskeline/issues/130 seems like it might be related to the prompt issue. It suggests https://github.com/judah/haskeline/wiki/ControlSequencesInPrompt as a potential workaround (as the actual fix PR seems to have gone stale). I lack a Windows machine to test it on.

Not sure about emojis. There seem to be some dragons here for Windows. That's a bummer; I thought that we were well into the age of Unicode.

ceedubs avatar Jul 27 '22 09:07 ceedubs

@ceedubs The emojis are less of a concern, and I see from the Windows issue you linked, that we will have to be patient anyhow. But the ANSI sequences being mishandled is more serious. I appeal to the developers of UCM to have a close look, because it used to work in M2 and (I think) M3. So something broke it.

meijeru avatar Jul 27 '22 16:07 meijeru

I found out that it looks fine on GitBash. Could be a reasonable temporary solution.

As for Emojis and ANSI sequences on Windows, I can confirm that they work. I spent a couple of days last week patching Elixir to make it work with a patched version of OTP 26, that has a new cross-platform TTY. Emojis cannot be displayed in cmd.exe or pwsh.exe. A modern terminal is needed, like Windows Terminal, WezTerm or Alacritty.

mardukbp avatar Aug 07 '22 15:08 mardukbp

I have tried Windows Terminal, but it does not help with the prompt. Where does one get GitBash?

meijeru avatar Aug 07 '22 20:08 meijeru

It comes bundled with Git for Windows.

mardukbp avatar Aug 08 '22 05:08 mardukbp

If it helps, when I run GitBash on its own, this works. And when I add git-bash.exe to windows terminal so that it opens in its own window and not in a terminal tab, it works. But when I get it to run in the terminal tab, by following this guide: https://www.timschaeps.be/post/adding-git-bash-to-windows-terminal/ the weird prompt is back image

jayber avatar Aug 11 '22 23:08 jayber

Yes, that is expected. The guide shows how to execute bash.exe (which is a shell, just like cmd.exe or pwsh.exe) within Windows Terminal (a terminal emulator, just like WezTerm or Alacrity). To my knowledge haskeline works on MinGW, which has its own terminal emulator and is the one used by GitBash.

mardukbp avatar Aug 12 '22 05:08 mardukbp

I have now downloaded the latest pre-release (723eaf6) and it shows the following:

 Now starting the Unison Codebase Manager (UCM)...

   _____     _             
  |  |  |___|_|___ ___ ___ 
  |  |  |   | |_ -| . |   |
  |_____|_|_|_|___|___|_|_|

  👋 Welcome to Unison!

  You are running version: 723eaf6

  Get started:

    📖 Type help to list all commands, or help <cmd> to view help for one command
    🎨 Type ui to open the Codebase UI in your default browser
    📚 Read the official docs at https://www.unison-lang.org/learn/
    🌎 Visit Unison Share at https://share.unison-lang.org to discover libraries
    👀 I'm watching for changes to .u files under C:\Users\rudol\Projects\Unison
.>`

At least some of the ANSI codes are gone, but other unreadables have taken their place! It looks like this has to do with color (the emojis look OK).

meijeru avatar Aug 16 '22 11:08 meijeru

In cmd.exe execute chcp 65001 before executing ucm. It tells the console to interpret program output as UTF-8-encoded strings. HTH

Am 16. August 2022 13:41:34 MESZ schrieb Rudolf Meijer @.***>:

I have now downloaded the latest pre-release (723eaf6) and it show the following:


Now starting the Unison Codebase Manager (UCM)...



  _____     _             

 |  |  |___|_|___ ___ ___ 

 |  |  |   | |_ -| . |   |

 |_____|_|_|_|___|___|_|_|



 👋 Welcome to Unison!



 You are running version: 723eaf6



 Get started:



   📖 Type help to list all commands, or help <cmd> to view help for one command

   🎨 Type ui to open the Codebase UI in your default browser

   📚 Read the official docs at https://www.unison-lang.org/learn/

   🌎 Visit Unison Share at https://share.unison-lang.org to discover libraries

   👀 I'm watching for changes to .u files under C:\Users\rudol\Projects\Unison

.>`

At least some of the ANSI codes are gone, but other unreadables have taken their place!

-- > Reply to this email directly or view it on GitHub:

https://github.com/unisonweb/unison/issues/3275#issuecomment-1216520390

You are receiving this because you commented.

Message ID: @.***>

mardukbp avatar Aug 16 '22 13:08 mardukbp

You're not supposed to have to chcp 65001 for ucm anymore, but I would want to know if that helps. If it does, that's a regression.

aryairani avatar Aug 16 '22 14:08 aryairani

I think a better fix than #3307 is probably along the lines of https://github.com/judah/haskeline/issues/130, but it means resurrecting our haskeline fork to apply the patch. I'm looking into reproducing the new behavior Rudolf posted.

aryairani avatar Aug 16 '22 14:08 aryairani

FYI: chcp65001 does not help.

meijeru avatar Aug 16 '22 15:08 meijeru

I downloaded the latest pre-release. WezTerm can correctly display ucm's welcome message. Maybe it is a good idea to take a look at the code and see what it is doing.

mardukbp avatar Aug 21 '22 12:08 mardukbp

Everyone should please include screen shots when describing visually weird or non-weird output 🙏

aryairani avatar Aug 22 '22 11:08 aryairani

Running ucm from latest pre-release (August 27th 2022):

  • on WezTerm with Powershell 7 as shell

grafik

  • on PowerShell 7

grafik

  • on Windows Terminal with Powershell 7 as shell

grafik

@aryairani I wonder why the Get Started section is empty. Any ideas?

mardukbp avatar Aug 28 '22 08:08 mardukbp

The release M4b improved things, but this issue is still not solved. @aryairani Why is it closed?

grafik

mardukbp avatar Oct 01 '22 11:10 mardukbp

I am on W11 using M4a with Windows Console Host and I have no problems anymore. Did not test M4b or M4c though.

meijeru avatar Oct 19 '22 13:10 meijeru

I can confirm that M4c works! Thanks a lot Unison team :)

mardukbp avatar Oct 22 '22 09:10 mardukbp