typelevel / scala

Typelevel Scala, a fork of Scala
http://typelevel.org/scala/
372 stars 21 forks source link

TLS 4 breaks sbt console somehow #175

Closed tpolecat closed 6 years ago

tpolecat commented 6 years ago

With the following minimal build when if you run console more than once JLine stops working.

foo$ tree
.
├── build.sbt
└── project
    └── build.properties

1 directory, 2 files
foo$ cat build.sbt 
scalaOrganization := "org.typelevel"
scalaVersion := "2.12.4-bin-typelevel-4"
foo$ cat project/build.properties 
sbt.version=1.0.3

Thus:

sbt:foo> console
[info] Updating {file:/private/tmp/foo/}foo...
[info] Done updating.
[info] Starting scala interpreter...
Welcome to Typelevel Scala 2.12.4-bin-typelevel-4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_144).
Type in expressions for evaluation. Or try :help.

scala> 42
res0: Int = 42

scala> 
[success] Total time: 7 s, completed Jan 3, 2018 10:05:09 AM
sbt:foo> console
[info] Starting scala interpreter...
Welcome to Typelevel Scala 2.12.4-bin-typelevel-4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_144).
Type in expressions for evaluation. Or try :help.

scala> ^[[A // pressed up arrow
42 // pressed up arrow
res0: Int = 42

scala> ^D

This doesn't happen with LBS.

I'm sorry. /cc @dwijnand

wedens commented 6 years ago

I think it's sbt issue, not TLS. Upgrading sbt to 1.1.4 fixed the problem for me.

tpolecat commented 6 years ago

Hm that doesn't fix it for me.

milessabin commented 6 years ago

Yeah, I also see this with 1.1.4.

This is very strange. I can't think of any reason why TLS 2.12.4 would differ from LBS 2.12.4 wrt JLine.

tpolecat commented 6 years ago

So, I originally saw this in my work project and isolated it to TLS. The minimal example above demonstrated it (and still does, even with sbt 1.1.4).

However we just switched our work project back to LBS (in part due to this issue) and the problem is still there! So there's some other interaction introduced by a plugin or something that's triggering this issue. I'll investigate.

tpolecat commented 6 years ago

I'm losing my mind. Now LBS consistently shows the JLine bug for me but it was working moments ago. There's something very fishy going on and i have no idea where to look.

foo$ tree
.
├── build.sbt
└── project
    └── build.properties

1 directory, 2 files

foo$ cat build.sbt 
scalaVersion := "2.12.5"

foo$ cat project/build.properties 
sbt.version=1.1.4

foo$ sbt
[info] Loading global plugins from /Users/rnorris/.sbt/1.0/plugins
[info] Loading project definition from /private/tmp/foo/project
[info] Updating ProjectRef(uri("file:/private/tmp/foo/project/"), "foo-build")...
[info] Done updating.
[info] Loading settings from build.sbt ...
[info] Set current project to foo (in build file:/private/tmp/foo/)
[info] sbt server started at local:///Users/rnorris/.sbt/1.0/server/b2c7b08bb0a88ab6cd9f/sock
sbt:foo> console
[info] Updating ...
[info] Done updating.
[info] Starting scala interpreter...
Welcome to Scala 2.12.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_144).
Type in expressions for evaluation. Or try :help.

scala> 1
res0: Int = 1

scala> 
[success] Total time: 6 s, completed Apr 20, 2018 10:21:43 AM
sbt:foo> console
[info] Starting scala interpreter...
Welcome to Scala 2.12.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_144).
Type in expressions for evaluation. Or try :help.

scala> ^[[A // pressed up arrow
1 // pressed up arrow
res0: Int = 1

scala> ^D
[success] Total time: 7 s, completed Apr 20, 2018 10:21:52 AM
sbt:foo> [info] shutting down server
tpolecat commented 6 years ago

Possibly an issue with the sbt-extras launcher? In any case I think maybe it's not a TLS issue, but rather something very strange that made it appear so. I'm fine closing this.

tpolecat commented 6 years ago

https://github.com/sbt/sbt/issues/4109

dwijnand commented 6 years ago

Looks like a race condition on some JVM global state mutation.

tpolecat commented 6 years ago

Workaround

initialCommands := "jline.TerminalFactory.get.init"
milessabin commented 6 years ago

Not sbt-extras ... I don't use it.

milessabin commented 6 years ago

Thanks for the workaround ... seeing as this appears to be down to SBT I'm going to close this.