groovysdkman

groovysh fails with nosuchmethod org.fusesource.jansi.AnsiConsole.wrapOutputStream


Does anybody use groovysh anymore? Is anybody else experiencing this issue?

Given my understanding of the java ecosystem and based on my research this error seems extremely likely going back quite aways but nobody seems to report it. I would think this is happening to everybody:

$ groovysh
FATAL: java.lang.NoSuchMethodError: 'java.io.OutputStream org.fusesource.jansi.AnsiConsole.wrapOutputStream(java.io.OutputStream)'
  1. I got this after installing java and groovy via sdkman (5.18.2) using git bash on Windows
  2. I tried the following combinations of java and groovy which are all reported to work according to the system requirements on the groovy download page : https://groovy.apache.org/download.html
java: 8, 11, 17 (amazon corretto)
groovy:  3.0.20, 4.0.1, 4.0.17

Solution

  • I was seemingly able to fix by replacing lib/jansi-2.4.0.jar with lib/jansi-1.12.jar but that seems a bit likely to cause other issues later that I haven't come across yet given the big difference in version numbers.

    p.s. I started to report this via Groovy Jira but changed my mind since it required registration. If anyone on the actual Groovy project can verify, then I would be happen to register and open an actual issue for it to be fixed.

    p.p.s. However... there are also a couple of suggestions to upgrade to JLine 3 which I would assume would fix this also if those issues are ever worked on. But given the issue list size in Jira, it doesn't look like the Groovy community is very active and/or interested in fixing their bugs :(