Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird repl output and interactions #757

Open
ghyatzo opened this issue Oct 31, 2024 · 7 comments
Open

Weird repl output and interactions #757

ghyatzo opened this issue Oct 31, 2024 · 7 comments

Comments

@ghyatzo
Copy link

ghyatzo commented Oct 31, 2024

hello, I've been using the repl but the experience has been a bit rough around the edges.
I am on windows and perhaps that is why, since i know that window support is just coming together.
For example, when I use the repl from the PS there seems to be a struggle with new lines and command submissions:

pkl0> lol = IntSeq(1,10)
lol = IntSeq(1,10)





/* to force the new input I had to close the statement
 * using ;
 */



;
pkl1> lol
IntSeq(1, 10)
pkl2> lil = IntSeq(1, 102);
lil = IntSeq(1, 102)pkl3> // new prompt not on a new line

copy pasting a multiline expression is impossible as it adds : characters on every new line?

pkl5> class MyClass {
        local test = IntSeq(30, 45)
: <---- this guy over here officer
JLine terminal: do you wish to see all 7 possibilities (0 lines)?ocal test = IntSeq(30, 45)
frequencies: Listing<Float>
      }

while the pasted content was

class MyClass {
	local test = IntSeq(30, 45)
	frequencies: Listing<Float>
}

There seems to be some jumbled up text in the error messages:

pkl0> IntSeq(1, 10).step(2.0)
IntSeq(1, 10).step(2.0)ΓÇôΓÇô Pkl Error ΓÇôΓÇô <---- Is this intended? if so, it's a bit weird :D
Expected value of type Int, but got type Float.
Value: 2.0

2620 | external function step(newValue: Int(isNonZero)): IntSeq
                                        ^^^
at pkl.base#IntSeq.step (https://github.com/apple/pkl/blob/0.26.3/stdlib/base.pkl#L2620)

1 | IntSeq(1, 10).step(2.0)
    ^^^^^^^^^^^^^^^^^^^^^^^
at  (repl:pkl0)

pkl1>

Is this an issue with PS?

@bioball
Copy link
Contributor

bioball commented Nov 1, 2024

Hm, I can't reproduce this on my machine (running Windows 11 on Parallels).

The weird characters suggests that your terminal is interpreting Pkl output as some other charset. This post on stackoverflow might help you: https://stackoverflow.com/questions/57131654/using-utf-8-encoding-chcp-65001-in-command-prompt-windows-powershell-window

This might solve your issue with terminating prompts too?

@ghyatzo
Copy link
Author

ghyatzo commented Nov 1, 2024

PS is using the us-ascii encoding:

PS C:\Users\########> $OutputEncoding


IsSingleByte      : True
BodyName          : us-ascii
EncodingName      : US-ASCII
HeaderName        : us-ascii
WebName           : us-ascii
WindowsCodePage   : 1252
IsBrowserDisplay  : False
IsBrowserSave     : False
IsMailNewsDisplay : True
IsMailNewsSave    : True
EncoderFallback   : System.Text.EncoderReplacementFallback
DecoderFallback   : System.Text.DecoderReplacementFallback
IsReadOnly        : True
CodePage          : 20127

out of curiosity, what is the encoding on your parallels VM?

Forcing it to UTF-8 doesn't seem to work?

PS C:\Users\#########> $OutputEncoding = [System.Text.UTF8Encoding]::new()
PS C:\Users\#########> $OutputEncoding


BodyName          : utf-8
EncodingName      : Unicode (UTF-8)
HeaderName        : utf-8
WebName           : utf-8
WindowsCodePage   : 1200
IsBrowserDisplay  : True
IsBrowserSave     : True
IsMailNewsDisplay : True
IsMailNewsSave    : True
IsSingleByte      : False
EncoderFallback   : System.Text.EncoderReplacementFallback
DecoderFallback   : System.Text.DecoderReplacementFallback
IsReadOnly        : True
CodePage          : 65001



PS C:\Users\#########> .\pkl.exe repl
Nov 01, 2024 3:21:28 PM org.jline.utils.Log logr
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
Welcome to Pkl 0.26.3.
Type an expression to have it evaluated.
Type :help or :examples for more information.

pkl0> :clear

;
pkl0>

What i noticed just now though, is this line WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information) (it was there also before changing encoding) may this be it?

EDIT: I've found out that I was using the built-in Windows PowerShell which apparently it is stuck at 5.1 and left there to die.
I've tried installing and using PowerShell7, which uses UTF-8 encoding OOB, but also there I have the same issue:

PowerShell 7.4.6
PS C:\Users\##########> $OutputEncoding

Preamble          :
BodyName          : utf-8
EncodingName      : Unicode (UTF-8)
HeaderName        : utf-8
WebName           : utf-8
WindowsCodePage   : 1200
IsBrowserDisplay  : True
IsBrowserSave     : True
IsMailNewsDisplay : True
IsMailNewsSave    : True
IsSingleByte      : False
EncoderFallback   : System.Text.EncoderReplacementFallback
DecoderFallback   : System.Text.DecoderReplacementFallback
IsReadOnly        : True
CodePage          : 65001

PS C:\Users\##########> .\pkl.exe repl
Nov 01, 2024 3:42:44 PM org.jline.utils.Log logr
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
Welcome to Pkl 0.26.3.
Type an expression to have it evaluated.
Type :help or :examples for more information.

pkl0> :clear      <---- Hit ctrl+c to exit here, but the issue persists.
PS C:\Users\##########>

Btw, how do I enable debug logging?

@bioball
Copy link
Contributor

bioball commented Nov 1, 2024

Here's what I see:

PS C:\Users\danielchao> $OutputEncoding

IsSingleByte      : True
BodyName          : us-ascii
EncodingName      : US-ASCII
HeaderName        : us-ascii
WebName           : us-ascii
WindowsCodePage   : 1252
IsBrowserDisplay  : False
IsBrowserSave     : False
IsMailNewsDisplay : True
IsMailNewsSave    : True
EncoderFallback   : System.Text.EncoderReplacementFallback
DecoderFallback   : System.Text.DecoderReplacementFallback
IsReadOnly        : True
CodePage          : 20127

Try running the steps in the answer here: https://stackoverflow.com/a/57134096/2460186.
Mainly, flow where you check a checkbox in the settings panel, and then restart Windows.

@translatenix
Copy link
Contributor

translatenix commented Nov 1, 2024

I've had console encoding issues with many Java programs on Windows.
The only solution that has universally worked for me was to enable "beta support for UTF-8" in Windows as shown here: oracle/graal#8593 (comment)

@ghyatzo
Copy link
Author

ghyatzo commented Nov 4, 2024

Sorry, this was an issue on my work computer and had to wait the weekend to get back to it.
Turning systemwide UTF-8, fixed the mangled characters, and some end line issues.
But didn't make everything smooth:

pkl5> 1 + 4
5
pkl6> IntSeq(1, 10).step(2)
IntSeq(1, 10).step(2)IntSeq(1, 10).step(2)                <--- double output?
pkl7> IntSeq(1, 10).step(2.0)
IntSeq(1, 10).step(2.0)–– Pkl Error ––                       <--- No new line? 
Expected value of type Int, but got type Float.
Value: 2.0

2620 | external function step(newValue: Int(isNonZero)): IntSeq
                                        ^^^
at pkl.base#IntSeq.step (https://github.com/apple/pkl/blob/0.26.3/stdlib/base.pkl#L2620)

1 | IntSeq(1, 10).step(2.0)
    ^^^^^^^^^^^^^^^^^^^^^^^
at  (repl:pkl7)

pkl8> :clear               <--- clear still needs a ; and does nothing.

;
pkl8>

also tab completion doesn't work.

@ghyatzo
Copy link
Author

ghyatzo commented Nov 4, 2024

I did some digging around.
It seems that the issue is with jline and missing either the Jansi or JNA libraries (on windows), quoting from the jline readme:

The dependencies are minimal: you may use JLine without any dependency on *nix systems, but in order to support windows or more advanced usage, you will need to add either Jansi or JNA library.

I am very not handy with JAVA, is there a way to include manually those dependencies? Does it need a Java SDK installed?

@translatenix
Copy link
Contributor

I am very not handy with JAVA, is there a way to include manually those dependencies? Does it need a Java SDK installed?

Unless you're using jpkl, there is no way to fix this yourself. Probably best to wait until this bug has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants