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

Update to ncurses causes sbt to throw an exception on startup #3240

Closed
amuttsch opened this issue Jun 2, 2017 · 42 comments
Closed

Update to ncurses causes sbt to throw an exception on startup #3240

amuttsch opened this issue Jun 2, 2017 · 42 comments
Labels
Milestone

Comments

@amuttsch
Copy link

amuttsch commented Jun 2, 2017

After upgrading ncurses, starting sbt shows the following error:

amu ~ >sbt
[ERROR] Failed to construct terminal; falling back to unsupported
java.lang.NumberFormatException: For input string: "0x100"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:766)
at jline.internal.InfoCmp.parseInfoCmp(InfoCmp.java:59)
at jline.UnixTerminal.parseInfoCmp(UnixTerminal.java:233)
...

This is because of a recent update to ncurses: http://invisible-island.net/ncurses/NEWS.html#index-t20170506

    + modify tic/infocmp display of numeric values to use hexadecimal when
          they are "close" to a power of two, making the result more readable.

steps

I'm using Arch Linux and have ncurses updated from 6.0+20170429-1 to 6.0+20170527-1. Just run sbt after installing the newest version and the error will appear.

problem

sbt uses jline for some terminal stuff. jline itself uses the infocmp utility provided by ncurses to determine terminal capabilities. It didn't expect a hex value and only parsed decimal values. This behaviour was already fixed: jline/jline2@c1b1676

sbt should update its jline dependency to include the fix.

expectation

sbt should start without issues.

notes

Using sbt version 0.13.15.

Is it possible to force sbt to use a locally compiled version of jline?

Stackoverflow issue: https://stackoverflow.com/q/44317384/2014080
jline issue: jline/jline2#281

@eed3si9n eed3si9n added the Bug label Jun 2, 2017
@eed3si9n
Copy link
Member

eed3si9n commented Jun 2, 2017

You could try putting the following in project/plugins.sbt:

dependencyOverrides += "jline" % "jline" % "2.15-SNAPSHOT"

but I'm not sure if it would fix because the metabuild still needs to load.

@amuttsch
Copy link
Author

amuttsch commented Jun 2, 2017

Thanks for the fast reply. Unfortunately, it still throws the exception. I will stay on ncurses version 6.0+20170429-1 for now until this issue is resolved :)

Edit: I forgot to mention the version: I'm using 0.13.15.

@eatobin
Copy link

eatobin commented Jun 2, 2017

Thank you @amuttsch for posting this and your reply on StackOverflow. I will watch for developments. Appreciated. :-)

@BardurArantsson
Copy link
Contributor

Yeah, I think we'll need a new release of jline. I took the liberty of submitting jline/jline3#127

@BardurArantsson
Copy link
Contributor

BardurArantsson commented Jun 3, 2017

Another potential workaround would be putting

-Djline.terminal=jline.UnsupportedTerminal

in the _JAVA_OPTIONS env var. That has some unpleasant side effects, though: You lose editing + up/down arrow + color + every single "Resolving ..." line will be printed to console. So only really usable if you're using sbt non-interactively.

@eed3si9n
Copy link
Member

eed3si9n commented Jun 4, 2017

@tmccombs
Copy link

tmccombs commented Jun 4, 2017

I also run into this problem with the scala REPL.

@grscheller
Copy link

Until the jline fixes get push out, you can temporarily "fix" the problem by downgrading ncurses after a Pacman `update:

    $ sudo pacman -Syu
    $ cd /var/cache/pacman/pkg
    $ sudo pacman -U ncurses-6.0+20170429-1-x86_64.pkg.tar.xz

@captainju
Copy link

I found using export TERM=xterm-color better than downgrading ncurses

@wsxarcher
Copy link

jline-2.14.4 is out with the fix

@amuttsch
Copy link
Author

amuttsch commented Jun 6, 2017

As well as jline-3.3.1

adriaanm added a commit to scala/scala that referenced this issue Jun 8, 2017
A recent ncurses upgrade breaks older jlines.

sbt/sbt#3240 (comment)
@Rogach
Copy link
Contributor

Rogach commented Jun 13, 2017

Are there any plans to release updated version with the fix any time soon?

export TERM=xterm-color fixes exceptions, but breaks some other stuff on my system.

(I can make the PR if needed)

@dwijnand
Copy link
Member

@Rogach A PR would be very helpful. Thank you.

@Rogach
Copy link
Contributor

Rogach commented Jun 13, 2017

@dwijnand Should I make 2 PRs - one for 0.13 branch, one for 1.0.x?

@dwijnand
Copy link
Member

That would be even more lovely! Thank you.

@gaydenko
Copy link

Is it possible to force old SBT projects (when SBT version is out of control) use new jline version on user's system base? (that is some magic in ~/.sbt)

Rogach added a commit to Rogach/sbt that referenced this issue Jun 13, 2017
Rogach added a commit to Rogach/util that referenced this issue Jun 13, 2017
A recent ncurses upgrade breaks older jlines.

sbt/sbt#3240
eed3si9n added a commit that referenced this issue Jun 13, 2017
Update jline dependency to 2.14.4 (#3240)
@vn971
Copy link

vn971 commented Jun 16, 2017

It would be great to release a bug-fix version of SBT!

@dwijnand
Copy link
Member

I think well be releasing a 0.13.16-M2 or 0.13.16 shortly, which thanks to @Rogach would have fixed this issue.

@dwijnand dwijnand added this to the 0.13.16 milestone Jun 16, 2017
@avdv
Copy link
Contributor

avdv commented Sep 18, 2017

@liquidarmour I cannot reproduce your problem. Are you seeing any errors from JLine or anything else? Do you have any global plugins enabled?

@liquidarmour
Copy link

@avdv I just checked. Intellij had put plugins in both 0.13 and 1.0 directories. I removed them and tried again. Still no luck.

Whatever I type does not appear.

There are no errors in the build and no jline errors visible.

akka-http-docker> sbtVersion
[info] 1.0.1
akka-http-docker> version
[info] 0.1.0-SNAPSHOT
akka-http-docker> sbtBinaryVersion
[info] 1.0
akka-http-docker>

@liquidarmour
Copy link

Sorry, should be more precise. The idea.sbt plugin was the only global plugin installed. With or without it the same behaviour ensues.

@djmcgill
Copy link

Confirmed that I get the same issue with @liquidarmour 's template. After running sbt test the shell won't echo any more. No JLine errors.

@avdv
Copy link
Contributor

avdv commented Sep 19, 2017

@liquidarmour, @djmcgill do you have any environment variables set? TERM maybe? which terminal emulator are you using? And which ncurses version?

I assume that this does not happen for other SBT tasks like compile, but only for test?

@liquidarmour
Copy link

@avdv I have done some more testing and it appears the problem only occurs when the console exits without user interaction.

I do not have TERM set on any of my machines. 3 so far that have seen this problem.

The problem exists in all the terminals I have used on multiple OS. It happens in Linux in the standard Mint terminal and in Terminator. On MacOS it happens in the standard terminal and in iterm.

If I type sbt test or sbt compile the sbt process ends once the task is complete. The terminal is then not echoing.
If I enter the sbt repl, run any tasks I want including, test and compile, and then hit ctrl-c the terminal works properly. sbt run work as well, in that ctrl-c restores a good terminal.

So there is definitely a problem when the sbt process exits automatically, and not when the user forces an exit.

@avdv
Copy link
Contributor

avdv commented Sep 20, 2017

Which sbt script are you using? The original or the one from sbt-extras ?

Could you run the sbt script with bash in verbose mode:

bash -v sbt

and post the output?

@liquidarmour
Copy link

~/liquidarmour/akka-http-docker $ bash -v sbt
#!/bin/sh
if [ -f "$HOME/.sbtconfig" ]; then
  echo "Use of ~/.sbtconfig is deprecated, please migrate global settings to /usr/local/etc/sbtopts" >&2
  . "$HOME/.sbtconfig"
fi
exec "/usr/local/Cellar/sbt/1.0.1/libexec/bin/sbt" "$@"
[info] Loading global plugins from /Users/jameswilliams/.sbt/1.0/plugins
[info] Loading settings from plugins.sbt ...
[info] Loading project definition from /Users/jameswilliams/liquidarmour/akka-http-docker/project
[info] Loading settings from build.sbt,version.sbt ...
[info] Set current project to akka-http-docker (in build file:/Users/jameswilliams/liquidarmour/akka-http-docker/)
[info] sbt server started at 127.0.0.1:5350
akka-http-docker> c~/liquidarmour/akka-http-docker $
~/liquidarmour/akka-http-docker $
~/liquidarmour/akka-http-docker $ bash -v sbt test
#!/bin/sh
if [ -f "$HOME/.sbtconfig" ]; then
  echo "Use of ~/.sbtconfig is deprecated, please migrate global settings to /usr/local/etc/sbtopts" >&2
  . "$HOME/.sbtconfig"
fi
exec "/usr/local/Cellar/sbt/1.0.1/libexec/bin/sbt" "$@"
[info] Loading global plugins from /Users/jameswilliams/.sbt/1.0/plugins
[info] Loading settings from plugins.sbt ...
[info] Loading project definition from /Users/jameswilliams/liquidarmour/akka-http-docker/project
[info] Loading settings from build.sbt,version.sbt ...
[info] Set current project to akka-http-docker (in build file:/Users/jameswilliams/liquidarmour/akka-http-docker/)
[info] Formatting 2 Scala sources {file:/Users/jameswilliams/liquidarmour/akka-http-docker/}root(test) ...
[info] Formatting 2 Scala sources {file:/Users/jameswilliams/liquidarmour/akka-http-docker/}root(compile) ...
[info] Reformatted 2 Scala sources {file:/Users/jameswilliams/liquidarmour/akka-http-docker/}root(compile).
[info] Reformatted 2 Scala sources {file:/Users/jameswilliams/liquidarmour/akka-http-docker/}root(test).
[info] Compiling 1 Scala source to /Users/jameswilliams/liquidarmour/akka-http-docker/target/scala-2.12/classes ...
[info] Done compiling.
[info] Run completed in 49 milliseconds.
[info] Total number of tests run: 0
[info] Suites: completed 0, aborted 0
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] No tests were executed.
[success] Total time: 7 s, completed 20-Sep-2017 11:16:55

Note the first run release the terminal properly. The second does not.

@avdv
Copy link
Contributor

avdv commented Sep 20, 2017

Oh, your sbt script is not a symlink to the sbt launcher script, so not much to see here. Could you do the same for the real script?

bash -v "/usr/local/Cellar/sbt/1.0.1/libexec/bin/sbt" test

I suspect that there will be a stty call which messes up the terminal after SBT has run...

@avdv
Copy link
Contributor

avdv commented Sep 21, 2017

@liquidarmour @djmcgill SBT 1.0.2 is out, which seems to fix the bug you are seeing: #3507

@djmcgill
Copy link

I'll update and report back @avdv

@liquidarmour
Copy link

OK. Looks like we have made progress.

Updating the sbt version in the project fixes the problem. The installed version of 1.0.1 works properly as long as the project has version 1.0.2

:-)

@avdv Thanks for your help.

@dwijnand
Copy link
Member

Nicely done @avdv.

odisseus added a commit to odisseus/akkapaint that referenced this issue Mar 21, 2018
mbloms added a commit to mbloms/lacasa that referenced this issue Apr 3, 2018
mbloms added a commit to mbloms/ncurses that referenced this issue Apr 7, 2018
    - modify tic/infocmp display of numeric values to use hexadecimal when
      they are "close" to a power of two, making the result more readable.

This patch fixes problems with i.a. earlier versions of jline and sbt<0.13.16.

* jline issue: jline/jline2#281
* sbt issue: sbt/sbt#3240
carlosdagos pushed a commit to carlosdagos/dots that referenced this issue Apr 19, 2018
Newer versions of ncurses cause SBT to fail, upgrading to 13.16+
resolves this issue.

sbt/sbt#3240
rtyley added a commit to guardian/play-googleauth that referenced this issue May 18, 2018
odisseus pushed a commit to odisseus/xylophone that referenced this issue Mar 11, 2019
sunnyking added a commit to virtualeconomy/v-wallet-generator that referenced this issue Dec 30, 2020
Fix sbt console crash on ubuntu 18.04 and 20.04, refer to
sbt/sbt#3240 (comment)
vglagoleva added a commit to spark-jobserver/spark-jobserver that referenced this issue May 24, 2021
Due to sbt/sbt#3240 previous
patch version of SBT was throwing and exception and not
coloring the results properly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests