unisonweb / unison

A friendly programming language from the future

Home Page:https://unison-lang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UCM on Windows gives strange prompt

meijeru opened this issue · 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.

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.

judah/haskeline#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 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.

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.

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

It comes bundled with Git for Windows.

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

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.

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).

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.

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

FYI: chcp65001 does not help.

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.

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

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?

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

grafik

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

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