sbtmacos-sierraterminfojline2

Strange problems with TERM=Apple_Terminal on macOS Sierra 10.12.3


I upgraded my MacBookPro to macOS Sierra and experienced a very odd behavior.

First, I used brew to install sbt as suggested in the doc: http://www.scala-sbt.org/download.html

Here's a simple test:

cd /tmp; echo $TERM; mkdir AT; cd AT; sbt -no-share -no-global -sbt-create
Apple_Terminal
Getting org.scala-sbt sbt 0.13.13 ...
downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.13.13/jars/sbt.jar ...
    [SUCCESSFUL ] org.scala-sbt#sbt;0.13.13!sbt.jar (1934ms)
...
downloading https://repo1.maven.org/maven2/jline/jline/2.13/jline-2.13.jar ...
    [SUCCESSFUL ] jline#jline;2.13!jline.jar (170ms)
...
Getting Scala 2.10.6 (for sbt)...
downloading https://repo1.maven.org/maven2/org/scala-lang/jline/2.10.6/jline-2.10.6.jar ...
    [SUCCESSFUL ] org.scala-lang#jline;2.10.6!jline.jar (70ms)
downloading https://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.4/jansi-1.4.jar ...
    [SUCCESSFUL ] org.fusesource.jansi#jansi;1.4!jansi.jar (80ms)
:: retrieving :: org.scala-sbt#boot-scala
    confs: [default]
    5 artifacts copied, 0 already retrieved (24494kB/25ms)
[ERROR] Failed to construct terminal; falling back to unsupported
java.lang.NumberFormatException: For input string: "`\327a\:f\241g\261h#i\360jjkkllmmnno\370p\370q\321rrssttuuvvwwxxy\262z\263{\271|\255}\243~\245"
    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] Loading project definition from /private/tmp/AT/project
[info] Updating {file:/private/tmp/AT/project/}at-build...
[info] Resolving org.scala-lang#scala-library;2.10.6 ...
[info] Resolving org.scala-sbt#sbt;0.13.13 ...
[info] Resolving org.scala-sbt#main;0.13.13 ...
[info] Resolving org.scala-sbt#actions;0.13.13 ...
[info] Resolving org.scala-sbt#classpath;0.13.13 ...
[info] Resolving org.scala-lang#scala-compiler;2.10.6 ...
[info] Resolving org.scala-lang#scala-reflect;2.10.6 ...
[info] Resolving org.scala-sbt#interface;0.13.13 ...
[info] Resolving org.scala-sbt#io;0.13.13 ...
[info] Resolving org.scala-sbt#control;0.13.13 ...
[info] Resolving org.scala-sbt#launcher-interface;1.0.0-M1 ...
[info] Resolving org.scala-sbt#completion;0.13.13 ...
[info] Resolving org.scala-sbt#collections;0.13.13 ...
[info] Resolving jline#jline;2.13 ...
[info] Resolving org.fusesource.jansi#jansi;1.11 ...
[info] Resolving org.scala-sbt#api;0.13.13 ...
[info] Resolving org.scala-sbt#classfile;0.13.13 ...
[info] Resolving org.scala-sbt#logging;0.13.13 ...
[info] Resolving org.scala-sbt#process;0.13.13 ...
[info] Resolving org.scala-sbt#compiler-integration;0.13.13 ...
[info] Resolving org.scala-sbt#incremental-compiler;0.13.13 ...
[info] Resolving org.scala-sbt#relation;0.13.13 ...
[info] Resolving org.scala-sbt#compile;0.13.13 ...
[info] Resolving org.scala-sbt#persist;0.13.13 ...
[info] Resolving org.scala-tools.sbinary#sbinary_2.10;0.4.2 ...
[info] Resolving org.scala-sbt#compiler-ivy-integration;0.13.13 ...
[info] Resolving org.scala-sbt#ivy;0.13.13 ...
[info] Resolving org.scala-sbt#cross;0.13.13 ...
[info] Resolving org.scala-sbt.ivy#ivy;2.3.0-sbt-2cf13e211b2cb31f0d3b317289dca70eca3362f6 ...
[info] Resolving com.jcraft#jsch;0.1.50 ...
[info] Resolving org.scala-sbt#serialization_2.10;0.1.2 ...
[info] Resolving org.scala-lang.modules#scala-pickling_2.10;0.10.1 ...
[info] Resolving org.scalamacros#quasiquotes_2.10;2.0.1 ...
[info] Resolving org.json4s#json4s-core_2.10;3.2.10 ...
[info] Resolving org.json4s#json4s-ast_2.10;3.2.10 ...
[info] Resolving com.thoughtworks.paranamer#paranamer;2.6 ...
[info] Resolving org.spire-math#jawn-parser_2.10;0.6.0 ...
[info] Resolving org.spire-math#json4s-support_2.10;0.6.0 ...
[info] Resolving org.scala-sbt#run;0.13.13 ...
[info] Resolving org.scala-sbt#task-system;0.13.13 ...
[info] Resolving org.scala-sbt#tasks;0.13.13 ...
[info] Resolving org.scala-sbt#tracking;0.13.13 ...
[info] Resolving org.scala-sbt#cache;0.13.13 ...
[info] Resolving org.scala-sbt#testing;0.13.13 ...
[info] Resolving org.scala-sbt#test-agent;0.13.13 ...
[info] Resolving org.scala-sbt#test-interface;1.0 ...
[info] Resolving org.scala-sbt#main-settings;0.13.13 ...
[info] Resolving org.scala-sbt#apply-macro;0.13.13 ...
[info] Resolving org.scala-sbt#command;0.13.13 ...
[info] Resolving org.scala-sbt#template-resolver;0.1 ...
[info] Resolving org.scala-sbt#logic;0.13.13 ...
[info] Resolving org.scala-sbt#compiler-interface;0.13.13 ...
[info] Resolving org.scala-lang#jline;2.10.6 ...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to at (in build file:/private/tmp/AT/)
[ERROR] Failed to construct terminal; falling back to unsupported
java.lang.NumberFormatException: For input string: "`\327a\:f\241g\261h#i\360jjkkllmmnno\370p\370q\321rrssttuuvvwwxxy\262z\263{\271|\255}\243~\245"
    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.JLine$.sbt$JLine$$terminal(LineReader.scala:85)
    at sbt.JLine$.withTerminal(LineReader.scala:88)
    at sbt.JLine$.usingTerminal(LineReader.scala:96)
    at sbt.JLine$.createReader(LineReader.scala:102)
    at sbt.FullReader.<init>(LineReader.scala:132)
    at sbt.BasicCommands$$anonfun$shell$1.apply(BasicCommands.scala:184)
    at sbt.BasicCommands$$anonfun$shell$1.apply(BasicCommands.scala:181)
    at sbt.Command$$anonfun$command$1$$anonfun$apply$1.apply(Command.scala:30)
    at sbt.Command$$anonfun$command$1$$anonfun$apply$1.apply(Command.scala:30)
    at sbt.Command$.process(Command.scala:93)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
    at sbt.State$$anon$1.process(State.scala:184)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.MainLoop$.next(MainLoop.scala:96)
    at sbt.MainLoop$.run(MainLoop.scala:89)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:68)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:63)
    at sbt.Using.apply(Using.scala:24)
    at sbt.MainLoop$.runWithNewLog(MainLoop.scala:63)
    at sbt.MainLoop$.runAndClearLast(MainLoop.scala:46)
    at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:30)
    at sbt.MainLoop$.runLogged(MainLoop.scala:22)
    at sbt.StandardMain$.runManaged(Main.scala:57)
    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)

[ERROR] Failed to construct terminal; falling back to unsupported
java.lang.NumberFormatException: For input string: "`\327a\:f\241g\261h#i\360jjkkllmmnno\370p\370q\321rrssttuuvvwwxxy\262z\263{\271|\255}\243~\245"
    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 jline.console.ConsoleReader.<init>(ConsoleReader.java:240)
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:232)
    at jline.console.ConsoleReader.<init>(ConsoleReader.java:220)
    at sbt.JLine$$anonfun$createReader$1.apply(LineReader.scala:103)
    at sbt.JLine$$anonfun$createReader$1.apply(LineReader.scala:102)
    at sbt.JLine$$anonfun$usingTerminal$1.apply(LineReader.scala:98)
    at sbt.JLine$$anonfun$usingTerminal$1.apply(LineReader.scala:96)
    at sbt.JLine$.withTerminal(LineReader.scala:89)
    at sbt.JLine$.usingTerminal(LineReader.scala:96)
    at sbt.JLine$.createReader(LineReader.scala:102)
    at sbt.FullReader.<init>(LineReader.scala:132)
    at sbt.BasicCommands$$anonfun$shell$1.apply(BasicCommands.scala:184)
    at sbt.BasicCommands$$anonfun$shell$1.apply(BasicCommands.scala:181)
    at sbt.Command$$anonfun$command$1$$anonfun$apply$1.apply(Command.scala:30)
    at sbt.Command$$anonfun$command$1$$anonfun$apply$1.apply(Command.scala:30)
    at sbt.Command$.process(Command.scala:93)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:96)
    at sbt.State$$anon$1.process(State.scala:184)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:96)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.MainLoop$.next(MainLoop.scala:96)
    at sbt.MainLoop$.run(MainLoop.scala:89)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:68)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:63)
    at sbt.Using.apply(Using.scala:24)
    at sbt.MainLoop$.runWithNewLog(MainLoop.scala:63)
    at sbt.MainLoop$.runAndClearLast(MainLoop.scala:46)
    at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:30)
    at sbt.MainLoop$.runLogged(MainLoop.scala:22)
    at sbt.StandardMain$.runManaged(Main.scala:57)
    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)

> 

In looking a the stack trace, I understand that sbt uses jline to query the capabilities of the terminal using the 'infocmp' process.

In this case, it shows:

infocmp
#   Reconstructed via infocmp from file: /usr/share/terminfo/41/Apple_Terminal
nsterm|Apple_Terminal|AppKit Terminal.app v41+ w/MacRoman charset (color),
    am, bw, msgr, xenl, xon,
    colors#8, cols#80, it#8, lines#24, ncv#37, pairs#64,
    acsc=+\335\,\334-\366.\3770#`\327a\:f\241g\261h#i\360jjkkllmmnno\370p\370q\321rrssttuuvvwwxxy\262z\263{\271|\255}\243~\245,
    bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=^M,
    csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
    cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C,
    cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
    dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K,
    enacs=\E(B\E)0, home=\E[H, ht=^I, hts=\EH, il=\E[%p1%dL,
    il1=\E[L, ind=^J, ka1=\EOq, ka3=\EOs, kb2=\EOr, kbs=\177,
    kc1=\EOp, kc3=\EOn, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC,
    kcuu1=\EOA, kent=\EOM, kf1=\EOP, kf2=\EOQ, kf3=\EOR,
    kf4=\EOS, op=\E[0m, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O,
    rmam=\E[?7l, rmkx=\E[?1l\E>, rmso=\E[m, rmul=\E[m,
    rs2=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h, sc=\E7,
    setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
    sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;,
    sgr0=\E[m\017, smacs=^N, smam=\E[?7h, smkx=\E[?1h\E=,
    smso=\E[7m, smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR,
    u7=\E[6n, u8=\E[?1;2c, u9=\E[c,

Indeed, the 'acsc' line matches the content that jline tried to parse as a number.

Switching terminal worked:

export TERM=xterm-256color
cd tmp; echo $TERM; mkdir XC; cd XC; sbt -no-share -no-global -sbt-create
xterm-256color
Getting org.scala-sbt sbt 0.13.13 ...
downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.13.13/jars/sbt.jar ...
    [SUCCESSFUL ] org.scala-sbt#sbt;0.13.13!sbt.jar (2051ms)
...
Getting Scala 2.10.6 (for sbt)...
downloading https://repo1.maven.org/maven2/org/scala-lang/jline/2.10.6/jline-2.10.6.jar ...
    [SUCCESSFUL ] org.scala-lang#jline;2.10.6!jline.jar (70ms)
downloading https://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.4/jansi-1.4.jar ...
    [SUCCESSFUL ] org.fusesource.jansi#jansi;1.4!jansi.jar (69ms)
:: retrieving :: org.scala-sbt#boot-scala
    confs: [default]
    5 artifacts copied, 0 already retrieved (24494kB/48ms)
[info] Loading project definition from /private/tmp/XC/project
[info] Updating {file:/private/tmp/XC/project/}xc-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to xc (in build file:/private/tmp/XC/)
> 

I also noticed that sbt 1.0.0-M4 seems to be unaffected by this terminal difference:

echo $TERM; mkdir NAT; cd NAT; sbt -no-share -no-global -sbt-create
Apple_Terminal
Getting org.scala-sbt sbt 1.0.0-M4 ...
downloading https://repo1.maven.org/maven2/org/scala-sbt/sbt/1.0.0-M4/sbt-1.0.0-M4.jar ...
    [SUCCESSFUL ] org.scala-sbt#sbt;1.0.0-M4!sbt.jar (78ms)
...
Getting Scala 2.11.8 (for sbt)...
downloading https://repo1.maven.org/maven2/org/scala-lang/modules/scala-xml_2.11/1.0.4/scala-xml_2.11-1.0.4.jar ...
    [SUCCESSFUL ] org.scala-lang.modules#scala-xml_2.11;1.0.4!scala-xml_2.11.jar(bundle) (92ms)
downloading https://repo1.maven.org/maven2/jline/jline/2.12.1/jline-2.12.1.jar ...
    [SUCCESSFUL ] jline#jline;2.12.1!jline.jar (111ms)
:: retrieving :: org.scala-sbt#boot-scala
    confs: [default]
    6 artifacts copied, 0 already retrieved (26456kB/26ms)
[info] Loading project definition from /private/tmp/NAT/project
[info] Updating {file:/private/tmp/NAT/project/}nat-build...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Set current project to nat (in build file:/private/tmp/NAT/)
> 

Same behavior with TERM=xterm-256color.

I'm baffled by this.

Has anyone experienced this problem?


Solution

  • Well, 1.0.x uses a newer JLine which could be the difference. I'm not sure how I have the following terminal but I can confirm that I'm using the following:

        eric$ echo $TERM
        xterm-256color
    

    I am using OS X 10.11.6 (El Capitan) so perhaps they changed the default terminal in the newer OS?

    This is not too much help but at least it confirms what you found. Also, I haven't found any problems with this configuration using 0.13.x but have added an issue for the 1.0.x dev version related to stty echo after running an sbt script. Refer to https://github.com/sbt/sbt/issues/2963