85

I have run into an ERROR with SBT today. It can best be shown with the sbt sbt-version command:

Run on 5/29/17:

eric@linux-x2vq:~$ sbt sbt-version
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option 
MaxPermSize=256M; support was removed in 8.0
[info] Set current project to eric (in build file:/home/eric/)
[info] 0.13.13

Run on 6/1/17:

eric@linux-x2vq:~$ sbt sbt-version
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option             
MaxPermSize=256M; support was removed in 8.0
[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)
at jline.UnixTerminal.<init>(UnixTerminal.java:64)
at jline.UnixTerminal.<init>(UnixTerminal.java:49)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at jline.TerminalFactory.getFlavor(TerminalFactory.java:209)
at jline.TerminalFactory.create(TerminalFactory.java:100)
at jline.TerminalFactory.get(TerminalFactory.java:184)
at jline.TerminalFactory.get(TerminalFactory.java:190)
at sbt.ConsoleLogger$.ansiSupported(ConsoleLogger.scala:123)
at sbt.ConsoleLogger$.<init>(ConsoleLogger.scala:117)
at sbt.ConsoleLogger$.<clinit>(ConsoleLogger.scala)
at sbt.GlobalLogging$.initial(GlobalLogging.scala:43)
at sbt.StandardMain$.initialGlobalLogging(Main.scala:64)
at sbt.StandardMain$.initialState(Main.scala:73)
at sbt.xMain.run(Main.scala:29)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:41)
at xsbt.boot.Boot$.main(Boot.scala:17)
at xsbt.boot.Boot.main(Boot.scala)

[info] Set current project to eric (in build file:/home/eric/)
[info] 0.13.13

No changes (that I know of) to either my SBT or Java setup.

Any ideas on what might be causing this or how to fix the error?

Thank you!

1
  • I have the same issue. The problem is, that infocmp has a hex value for color#0x100 which jline.UnixTerminal cannot parse. The bug was already fixed: github.com/jline/jline2/commit/…
    – amuttsch
    Jun 2, 2017 at 13:00

10 Answers 10

192

I had the same issue, especially when the TERM environment variable is set to xterm-256color. Setting it to a different value fixed the issue for me, e.g.

export TERM=xterm-color
9
  • 2
    works for me, arch user. Arch Kernel 4.11.3-1-ARCH, sbt version 2.5.15 "Streamy"
    – CybeX
    Jun 14, 2017 at 14:55
  • added this at the top of my sbt launcher
    – Utgarda
    Jul 3, 2017 at 6:05
  • 2
    Also works for me, Arch Linux. Added that line to my ~/.bashrc file. Aug 9, 2017 at 23:37
  • 1
    Works for Macos. I use zsh as my shell. Mar 1, 2018 at 5:21
  • 4
    Works for me on Ubuntu 18.04
    – Mule
    Jun 28, 2018 at 14:54
56

I found the package which causes this issue: ncurses. I downgraded ncurses to version ncurses-6.0+20170429-1 (I am using Arch Linux) and SBT starts just fine.

Steps for Arch Linux:

cd /var/cache/pacman/pkg
sudo pacman -U ncurses-6.0+20170429-1-x86_64.pkg.tar.xz # or some other older version

Steps for Mac: see https://github.com/jline/jline2/issues/281

I think this issue was introduced with ncurses version 20170506, see: 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.

I filed an issue on the SBT issue tracker: https://github.com/sbt/sbt/issues/3240

Edit: SBT version 0.13.16 includes the fix for this problem.

3
  • 2
    Thank you for this and your post to github. I noticed the problem immediately after an openSUSE Tumbleweed update yesterday. ncurses! I will watch for developments. Appreciated. :-)
    – ericky
    Jun 2, 2017 at 15:04
  • how could I do that on Ubuntu? Apr 23, 2019 at 13:17
  • The correct way to actually fix all this is upgrade scala from 2.11.X to 2.13.X. See: github.com/sbt/sbt/issues/3240#issuecomment-325899575 The guilty lib is jline. :D Jun 2, 2020 at 19:22
25

You can add export TERM=xterm-color to the top of /usr/share/sbt/bin/sbt because $HOME/.sbtconfig is deprecated.

2
  • 2
    The file /usr/share/sbt/bin/sbt is very likely to be installed as part of the sbt package by a package manager. Any edits to this file might be removed upon the sbt package being updated, which could be either invisible to a particular user (if some other person is updating the sbt package) or overwritten in a moment of forgetfulness.
    – Taylor R
    Dec 6, 2018 at 16:21
  • Well that would be good because it's apparently fixed in later versions. Mar 24, 2019 at 15:50
22

sbt command is just a script. It load $HOME/.sbtconfig at the very beginning, so just put

export TERM=xterm-color

as @user3113045 said in the conf file, sbt will work. In that case your other term commands will still use xterm-256color.

2
  • 1
    I put export TERM=xterm-color in my ~/.bashrc and it works fine.
    – ChikuMiku
    Jul 12, 2018 at 19:04
  • First, use which sbt to find the folder that needs to put the line in.E.g., mine is/usr/local/opt/[email protected]/bin/sbt. I put the line in it and it worked
    – Chau Pham
    Nov 13, 2018 at 17:30
9

This resolved the issue in my case (Linux Users):

  1. Open your terminal
  2. Navigate to your project directory
  3. type "export TERM=xterm-color" in your terminal without the quotes
  4. Hit ENTER

That is all and then you are good to go.

2
  • I put the statement in my .bashrc (Ubuntu). Worked perfect. I assume it will work for me in Fedora as well.
    – wayneeusa
    May 16, 2020 at 20:24
  • Worked for me on an ec2 instance in a cluster. Thanks! Mar 25, 2021 at 15:30
7

One year passed... now it happened to me.


So, ncurses did change, and the corresponding sbt part was ...I guess... probably only implemented based on random guessed tests and observations/bugs and not any spec nor RFC. (So far, sbt is the only program with this ncurses issue that I know of.)

In case you can't simply upgrade sbt nor downgrade ncurses, you could change the TERM environment variable as mentioned in the other answers.

trivial fix:

If your sbt script is some bash script (most likely, unless you run DOS' .bat files)

$ file /usr/bin/sbt
/usr/bin/sbt: Bourne-Again shell script, ASCII text executable

, then it might suffice to add this workaround:

TERM="${TERM/xterm-256color/xterm-color}"
2
  • 2
    Rather than file /usr/bin/sbt, you might want to use file -L `which sbt` to make sure that the sbt that is on the user's path is checked and that any symbolic links are followed.
    – Taylor R
    Dec 6, 2018 at 16:17
  • indeed. you could also add another script as wrapper and put that in PATH shadowing the original.
    – comonad
    Dec 11, 2018 at 14:51
3

If you can, change sbt version in build.properties to higher. 13.16 work for me.

2

For Ubuntu 20.04 Users, Open your terminal and run the bellow CMDs

  • Go to this "/usr/share/sbt/bin" directory ( $ cd /usr/share/sbt/bin )
  • give the permission to edit file ( $ sudo chmod -R 777 sbt )
  • Open the sbt text file in this directory ( $ nano sbt )
  • Add this "export TERM=xterm-color" cmd in top and save ( Ctrl + X )

Ex:-

#!/usr/bin/env bash
export TERM=xterm-color
set +e
1

I can't write a comment as my score is too low, but user3113045's answer worked when I added export TERM=xterm-color to my .zshrc file

0

I faced this issue when i am using activator which uses sbt internally. I am using Ubuntu and this error was frustrating me. I started facing this issue when i ran

$ activator gen-idea (tool which as per the intellij is legacy)

After this i tried to delete all the cache that this tool generated.

I deleted the .ivy and .sbt directories from my home folder and ran the activator cleanFiles compile command which resolved my issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.