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

IllegalArgumentException: Unknown ansi-escape [0;93m at index 19 inside string cannot be parsed into an fansi.Str #1328

Open
jk-1 opened this issue Mar 6, 2023 · 1 comment

Comments

@jk-1
Copy link

jk-1 commented Mar 6, 2023

I'm trying to run simple ssh-ping command using ammonite but it fails.

ssh-ping is part of small optional Ubuntu package ssh-tools.

On Mate terminal command output when pinging non-existing host is this:

ssh-ping -q -W 2 -c 1 -p 22 myhost
SSHPING myhost

--- myhost ping statistics ---
1 requests transmitted, 0 requests received, 100% request loss

Output is very colored and there is no option in ssh-ping to turn off colors.

Running this with standard Scala REPL works fine:

scala
Welcome to Scala 2.12.8 (OpenJDK 64-Bit Server VM, Java 11.0.18).
Type in expressions for evaluation. Or try :help.

scala> import scala.sys.process._
import scala.sys.process._

scala>  val res = "ssh-ping -q -W 2 -c 1 -p 22 myhost".!!
res: String =
"SSHPING myhost

--- myhost ping statistics ---
1 requests transmitted, 0 requests received, 100% request loss
"

scala> 

But when trying to run the same with Ammonite, I get repeatedly this exception:

amm
Loading...
Welcome to the Ammonite Repl 2.4.0 (Scala 2.12.13 Java 11.0.18)
jk-kptmp@ import scala.sys.process._  
import scala.sys.process._ 

jk-kptmp@ val res = "ssh-ping -q -W 2 -c 1 -p 22 myhost".!! 
java.lang.IllegalArgumentException: Unknown ansi-escape [0;93m at index 19 inside string cannot be parsed into an fansi.Str
  fansi.ErrorMode$Throw$.handle(Fansi.scala:419)
  fansi.ErrorMode$Throw$.handle(Fansi.scala:407)
  fansi.Str$.apply(Fansi.scala:272)
  fansi.Str$.implicitApply(Fansi.scala:227)
  pprint.Renderer.$anonfun$rec$33(Renderer.scala:149)
  pprint.Result$.fromString(Result.scala:53)
  pprint.Renderer.rec(Renderer.scala:149)
  pprint.PPrinter.tokenize(PPrinter.scala:104)
  ammonite.repl.FullReplAPI$Internal.print(FullReplAPI.scala:106)
  ammonite.repl.FullReplAPI$Internal.print$(FullReplAPI.scala:61)
  ammonite.repl.FullReplAPI$$anon$1.print(FullReplAPI.scala:34)

It also fails with Ammonite and os.lib's os.proc(...).call(...) -function.

Versions: Ubuntu 20.04, Ammonite Repl 2.4.0 (Scala 2.12.13 Java 11.0.18)

I opened this issue here because don't know whether this is fansi issue, ammonite issue or common for both packages.

@robcd
Copy link

robcd commented Apr 9, 2024

Hi. Something similar happens to me when I try to use the requests-scala library
to .get an image file, from the repl cmdline - it works fine in a .sc script.

% amm
Loading...
Welcome to the Ammonite Repl 3.0.0-M1 (Scala 3.3.3 Java 21.0.2)
@ val response = requests.get("https://httpbin.org/image/webp") java.lang.IllegalArgumentException: Unknown ansi-escape at index 754 inside string cannot be parsed into an fansi.Str

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

2 participants