Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

i really would like sbt and its console to work under cygwin any way you think it can be done?

Tags:

scala

cygwin

sbt

i have this issue (https://github.com/sbt/sbt/issues/562) basically when I try to get a console it says:

[ERROR] Failed to construct terminal; falling back to unsupportedjava.lang.IllegalArgumentException: Invalid terminal type: jline.UnixTerminal

also you cant use backspace

you basically cannot use sbt in cygwin (in dos is fine but cygwin is a much nicer environment) and have voiced my concern there

i have tried several workaround i found on the net but they are all for old releases and no use now

was just wondering if you know of any workaround?

thanks

like image 238
mbrambley Avatar asked Jun 15 '13 14:06

mbrambley


1 Answers

The following works for me (mostly, see note at bottom):

  1. Use the mintty shell. I believe this is the default shell for new cygwin installs but has been included as an alternative for a while. If mintty.exe exists in your <cygwin home>\bin folder then it's ready to use, else it can be installed through the typical cygwin package selection from the setup.exe.
  2. Open a mintty window, right click anywhere, go to Options... -> Keys, and make sure Send Backspace as ^H is checked. This will allow the REPL to correctly interpret backspaces.

For just running the Scala REPL that should be all you need, but attempting to run sbt console can still produce that exception. To get past that, run sbt without any arguments to get to the sbt prompt. From there execute:

eval System.setProperty("jline.terminal", "scala.tools.jline.UnixTerminal")

then

console

or, as a single command (with both semi-colons being important):

; eval System.setProperty("jline.terminal", "scala.tools.jline.UnixTerminal") ; console


From what I can tell, this is caused at least in part by the Scala REPL and the sbt prompt using incompatible versions of JLine. In particular, it looks like the Scala REPL created their own wrappers around the library and are using that while sbt is using the JLine library directly.

Note

One limitation that I continue to run into is that the REPL wraps at column 80 even if the shell window has more horizontal space. Not only that, but when the REPL wraps like this it overwrites the same line rather than advancing to the next, and pulling long lines from history ends up pushing the cursor above the line you're actually editing.

like image 70
hayden.sikh Avatar answered Oct 17 '22 18:10

hayden.sikh