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

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

The following works for me (mostly, see note at bottom):
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.
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.

Related

Elixir: VS Code ExUnit cannot find Mix

I cannot load or run my tests, from within VS Code.
I'm a new user to Elixir, and to VS Code. I'm running Lubuntu 21.10 (Impish). I've downloaded Erlang/OTP 25 (.deb), and Elixir 1.14 (precompiled binary in /usr/share/elixir), and can get anything I need running in a Bash terminal. Again, in a standard QTerminal window,
erl, iex, mix, elixir, etc. all work fine.
In VS Code, however, I get some errors. I feel stupid, but I'm coming from Sublime Text, so please forgive me.
In the left pane of VS Code, ExUnit shows an error (red):
Clicking on this error gives me this, on the bottom right pane. The command line options, passed to mix test, seem to be the default configuration:
This result is bizarre to me, because I can open the integrated terminal, execute /bin/sh, and then run the exact mix test line that's displayed:
/usr/share/elixir/bin has been added to my PATH variable, in ~/.bashrc, ~/.profile, and /etc/environment.
However, I am further confused by all tests being excluded, and wonder if there's some connection to the core issue:
Note that I can run my tests just fine, using different command line options. I've tried adding tags, but that didn't fix the problem.
I tried Google'ing this, and played around with my settings. Here is what I have configured in the "User" settings.json, and I made sure nothing overrides this in "Workspace" settings:
Changing the useNativeTesting setting doesn't solve the problem.
On another (?) note, I get a "failed to run elixir" upon VS Code startup:
Again, I have no problem running commands from a Linux terminal, or from a terminal within VS Code.
Plot twist: If I remove the precompiled Elixir 1.14, and downgrade to an older version, via apt, the problem goes away. But Lubuntu 21.10 doesn't offer Elixir 1.14, and I'm really into using the new dbg() feature.
But for now, I cannot load or run my tests, from within VS Code, apparently because Mix cannot be found.
Thanks to Daniel Imms, from the VS Code team, for answering my question on Twitter:
"Try moving where ever you init mix and elixir (.bashrc?) into your .bash_profile and then logging out and in again or restarting. I'm guessing it's in your bashrc which doesn't run in non-interactive sessions like in tasks."

Backspace behavior in interactive shell

I'm trying to use the Scala interactive shell, but the backspace key's behavior is strange. I'm finding that backspace does seem to delete the previous character, but it doesn't display that way on the line I'm typing... the cursor moves forward instead of backward. This makes it impossible to see what the current input line looks like.
I'm using Scala 2.11.12. I'm working in a terminal window on a Linux system, but xrdp'ing into the Linux host from a Windows 10 laptop. The backspace key works fine outside Scala (in zsh).
As a workaround, is there any control character that tells Scala to redisplay the current line? (Old OS's used to support characters that perform that function, if memory serves, but they haven't been necessary for a couple decades or so.)
I also encountered the same problem and improved by changing the setting of pyenv.
If the global setting of pyenv is not system, try changing to system.
Example:
$ pyenv versions
* system (set by /Users/*****/.pyenv/version)
2.7.10
3.5.0
anaconda3-5.2.0
Perhaps it's a bug of JLine, which scala use as a replacement of readline. But, if I empty the folder ~/.pyenv/shims, scala works fine. Then I execute pyenv rehash (which will bring back the files under shims), scala failed!
Then I remove the files in ~/.pyenv/shims half by half and it's a file named infocmp makes the difference. And it's not the content in it, but the exec permission that matters, i.e. chmod a-x ~/.pyenv/shims/infocmp will make scala work fine, but chmod a+x ~/.pyenv/shims/infocmp, even if infocmp is empty, the problem will occur!
May be I am close to the truth, but for now we can use chmod a-x ~/.pyenv/shims/infocmp to work around. And it needs only to be run once, because pyenv rehash will not overwrite a file if it already exists.

Scala Console in IntelliJIDEA neither acccepts input nor prints output, comand works from temrinal

I have a "Scala/Simple module with attached Scala SDK" type project in IntelliJIDEA with which I was easily able to build and setup a couple of application configurations. A Scala workspace also works fine, but when I try to create and run a Scala Console configuration the terminal comes up, the Scala Repl appears to run fine, in that it gives me the Welcome to Scala message and prints an initial "scala>". However, although autocompletion works, the Repl otherwise appears dead to the world: nothing is returned or printed, and when I restarted and entered a one-liner to write some text to a file to test if it was just an ouptut-capture issue, that file did not appear.
I am running IntelliJIDEA 15.0.2 / idea-IU-143.1184.17 on Debian.
When I copy the command being run by IntelliJIDEA and run from a console, it works fine; command copied from IntelliJIDEA Scala Console follows:
/usr/lib/jvm/java-7-openjdk-amd64/bin/java -Djline.terminal=NONE -Didea.launcher.port=7543 -Didea.launcher.bin.path=/usr/local/idea-IU-143.1184.17/bin -Dfile.encoding=UTF-8 -classpath /home/pacs/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.7.jar:/home/pacs/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.11.7.jar:/home/pacs/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-2.11.7.jar:/home/pacs/.IntelliJIdea15/config/plugins/Scala/lib/scala-plugin-runners.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/charsets.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/compilefontconfig.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/icedtea-sound.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/java-atk-wrapper.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/javazic.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jce.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/jsse.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/management-agent.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/resources.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rhino.jar:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar:/home/pacs/IdeaProjects/scap/out/production/scap:/usr/local/idea-IU-143.1184.17/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain org.jetbrains.plugins.scala.compiler.rt.ConsoleRunner -usejavacp
I'm rather new to the JetBrains family of IDEs so I may be missing something obvious; does anyone have any ideas?
EDIT: I tried this on IntelliJIDEA 15.0.0 on OS X with scala 2.10.6 and JDK 1.8 with the same result so I am inclined to believe this is not a JDK, Scala, or OS-specific problem.
OK, finally figured this out: it's not a normal console where you press enter; instead you use whatever keymap goes to Plug-ins/Scala/Execute Console Statement-- probably Ctrl+Enter or ⌘+Enter.
Other people seem to have been stumped also:
Scala console won't work, IntelliJ
The IntelliJIDEA console is very nice once you know this; with autocompletion, auto-formatting, and no issues with multiline code. If I had one request though, it would be to ask the JetBrains team to please add something to the Scala Console welcome message which indicates that this is not a normal console and maybe a quick hint on how to use it.

eclipse debug perl curses

I am writing a Perl program that uses curses for output and move the cursor, and color characters. Previously, when I was working under windows I use Komodo it was able to run an external console.
Now I work in Linux environment and use eclipse + epic. If you try to just run the script, it uses the internal console eclipse, which is very cut. You can just run the script using external tool, but I'm interested to debug using external console window. Is this possible?
Unfortunately, use of a File and /dev/pty/1 does not help in solving my problem.
The fact is that in this case it is impossible to get the characters introduced in the console through curses getch(). Always returned 1 instead code of pressed key.
Here is an answer that will take you most of the way (based on post #6 of: http://ubuntuforums.org/showthread.php?t=743131, although since then, in the "Indigo" and "Juno" versions of Eclipse, things have changed somewhat, and this answer is up to date):
Go to "Run -> Debug configurations". Click on the (fourth) "Common" tab. Go to the third frame from top, and there, check-mark the checkbox which says: "File". Enter the file name of the console window you want your output in.

eclipse plugin: run command in console, get stdin

I'm making an eclipse plugin where I want to run a system command, and have the output of the command go to the eclipse console. I know how to do this via http://wiki.eclipse.org/FAQ_How_do_I_write_to_the_console_from_a_plug-in%3F
The problem I don't know how to solve, is to allow interactive input from the console for this command.
In essence, I want to kick off a command which runs in the console. The user can interact with this command (via stdin). I then want my plugin code to get a callback when the command has finished (or user has manually stopped/terminated the command in the console). Getting the return code of the completed program would be nice as well.
For simplicity sake, lets use the unix 'passwd' command as the example (this is the first common cmd I could think of that both has output and prompts for input). I don't need to hide the stdin however.
For reference, the command I'm trying to call is the CakePHP bake shell.
I assume that you got yourself a MessageConsole, like in the FAQ. Then it should be possible to use messageConsole.getInputStream().read() in a loop to get your input (but I have not tested this). See also the documentation of the IOConsoleInputStream for more options.
On the other hand I'm not sure why you are creating your own plugin to do that. The standard console implementation in Eclipse does exactly what you want. You can see that by running a small Java application, where you can use that console for input and output as well.