Two problems with sbt in cygwin / vista - scala

I am using cygwin 1.77 on windows vista.
I'm facing problems with the output from sbt in the shell.
Some relevant environment vars:
TERM=cygwin
CYGWIN=server
LANG=C.UTF-8
(1) When I type sbt test the shell contains a lot of unprintable characters:
How can I fix this ?
My sbt shell script looks like this:
dir=`dirname $0`
stty -icanon min 1 -echo > /dev/null 2>&1
java -Djline.terminal=jline.UnixTerminal -Xmx512M -jar
`cygpath -w $dir`/sbt-launch-0.7.4.jar "$#"
stty icanon echo > /dev/null 2>&1
(2) The sbt command cannot find the scalatest jar & I don't know how to configure it to download it via ivy. It works if I drop the jar into the lib folder.

Regarding 1):
The way the Cygwin console works is that there's a part of the Cygwin DLL that maps Unix terminal control sequences to Windows console API calls. Since that terminal emulation is part of the Cygwin DLL, it is not available to non-Cygwin programs such as the Java runtime. Instead, java will be talking directly to the Windows console, which doesn't understand escape sequences. Hence they appear directly on screen.
There are a few ways you could address this:
Tell Java/Scala to use the Windows console API instead of Unix control sequences. I guess removing the -Djline.terminal=jline.UnixTerminal option would do that.
Set the CYGWIN=tty option. With that, programs invoked in the Cygwin console have their I/O connected to a "pseudo terminal" (pty) device instead of being connected directly to the console window. This makes the terminal emulation features available to non-Cygwin programs, but it means that programs that use the Windows console API will no longer work correctly.
Use one of Cygwin's other terminal emulators: mintty, xterm, rxvt(-unicode). These offer better terminal emulation and more sensible user interfaces than the default console, but again at the cost of not supporting programs that use the Windows console API.
(Btw, the CYGWIN=server option is obsolete; the feature that it enabled is always on anyway.)

Related

How to get Emacs on MINGW64 (Windows 10)

I currently use MINGW64 (Git Bash) as my terminal on my Windows 10 machine. It works great, I like it, but it only has Vim installed as an editor and I prefer Emacs. I'm unfortunately having a really awful time getting it to work in my terminal.
What's weirder still is that I have Emacs working in Cygwin64; but I don't like using that as my terminal. The most logical fix is simply that it Emacs to my Path ENV, however that doesn't seem to help (perhaps I'm doing that wrong?). I just get bash: emacs: command not found. I found a command to install it, using Pacman, however the Pacman command cannot be found either (which is weird because I thought that was installed by default with MINGW64.
Would love any and all help on this.
A couple of options:
Use Cygwin and the Cygwin emacs. Consider your Cygwin environment completely separate from Windows, so set your PATH from within the .bashrc, not within Windows. Launch emacs from the bash command-line.
Use the Emacs Windows binary distribution, but point to the utilities within Cygwin (there's an emacs package to help with this). Again, launch from the bash command line to inherit the bash environment within emacs.
Use the Windows Subsystem for Linux, with a Linux installation, and stick with emacs from there. You get the best of the Linux world, and access to the Windows directories and files as well.
My goto choice for MANY years was the Emacs Windows binary in conjunction with Cygwin. Once I started using the WSL, however, it just worked a lot better, in a clean Linux environment, and I could get terminal and GUI emacs (and other apps) running using the VcXsrv X Server. WSL has a version that directly supports X Windows, but I don't care for the windowing environment it uses, so I stick with VcXsrv.

Which shell should be used for Bazel under Windows 10

Usually, on Windows, I use PowerShell (default shell) to call a Bazel command such as bazel build. As far as I understand Bazel makes use of MSYS2 to call and execute commands such as curl, zip or git for instance. Therefore, I wonder if I should use the MSYS2 bash terminal instead of PowerShell. Can there be any problems when using Powershell instead of the MSYS2 bash terminal? Or doesn’t it matter?
As its mentioned here by developers of bazel, using MSYS or MSYS2 is the best choice. Personally I prefer MSYS* over cmd or PowerShell for any thing.
In the current master there was recently an update of the documentation exactly about this issue:
As of 2020-01-15, we do not recommend running Bazel from bash – either
from MSYS2 shell, or Git Bash, or Cygwin, or any other Bash variant.
While Bazel may work for most use cases, some things are broken, like
interrupting the build with Ctrl+C from MSYS2). Also, if you choose to
run under MSYS2, you need to disable MSYS2’s automatic path
conversion, otherwise MSYS will convert command line arguments that
look like Unix paths (e.g. //foo:bar) into Windows paths. See this
StackOverflow answer for details.

How can I redirect linux terminal output to Eclipse console?

I am trying to redirect Terminal output to Eclipse console using external tools where I specified Terminal path (for example /usr/bin/xterm). When I run this tool it opens Terminal outside eclipse. When I did same thing in Windows 7, setting external tool location to Windows\System32\cmd.exe it ran inside Eclipse console. I wonder how I can make Terminal (in Ubuntu 14.04) work the same way.
You should use /bin/sh as command interpreter.
In Windows, cmd.exe combines two functions—interpreting commands and displaying terminal window. In Unix these functions are strictly separated. /bin/sh interprets commands and /usr/bin/xterm (or /usr/bin/x-terminal-emulator) displays terminal window, inside which it runs /bin/sh (or other shell like /bin/bash, /bin/zsh etc.) to interpret commands.
So if you ask Eclipse to run something via /usr/bin/xterm, it will appear in a new window, because that's what XTerm does. If you just want Eclipse to capture the output, ask it to run it directly via /bin/sh.

Chmod u+x windows cmd

I'm trying to install Scalatra on windows seven and need to change a file to executable...the Scalatra documentation says to do this, which is unix. What is the windows equivalant?
chmod u+x srt
You can simply open the relevant folder with a unix command prompt (I use git bash) and execute the unix commands from there
To get scalatra-sbt going on Windows, either port you own sbt.bat from scalatra-sbt, or install chmod via cygwin.
Assuming you've successfully installed the rest of Conscript and giter8, you can start a project that downloads scalatra-sbt. From there, one can look through the ./sbt source, and port the bash script functionality to your own windows specific script, or install a unix compatibility layer into Windows. If you go down the "windows specific script" route, perhaps the scalatra-sbt would appreciate the project contribution.
The "unix compatibility layer" route will eventually allow you to run ./sbt. chmod is a unix command line function, and is provided in a default package of the tool set cygwin, which provides a complete lunix-like environment. Once inside a cygwin terminal, you can chmod your file, as mentioned in the scalatra-sbt first project.
Diving into the contents of ./sbt from scalatra-sbt, this is actually unix script wrapper around the scala build tool (also referred to, confusingly, as sbt). If while trying to run ./sbt you get strange '\r' errors, install the cygwin package dos2unix, and then run it on the sbt file. If you run into any "which: no curl in..." or "which: no wget in..." errors, go back to the cygwin installer, find those packages such as wget, and then install those programs.
By the way, the last thing the scalatra-sbt script runs is the Scala build tool. The Scala build tool sbt itself has many reported issues with cygwin's default configuration, so you will likely need to do more research. Depending on what issues you're running into on your specific setup, you may need to make changes to the end of the ./sbt script to adjust the parameters used to launch the Scala build tool.

Eclipse PyDev use remote interpreter

is there a posibility to make eclipse PyDev use a remote Python interpreter?
I would like to do this, as the Linux Server I want to connect to has several optimization solvers (CPLEX, GUROBI etc.) running, that my script uses.
Currently I use eclipse locally to write the scripts, then copy all the files to the remote machine, log in using ssh and execute the scripts there with "python script.py".
Instead I hope to click the "run" button and just have everything executed within my eclipse IDE.
Thanks
Unfortunately no. You can remotely connect to your Linux server via Remote System Explorer (RSE). But can't use it as a remote interpreter. I use Pycharm. You can use the free Community Edition or the Professional Edition for which you have to pay for it. It is not that expensive and it has been working great for me.
As Adel says, this is probably not possible with the Remote System Explorer, or the normal Run button,
but you can automate the process you currently use. I had to do this for a few weeks when the fan was broken
in my laptop, and doing any significant computation there made it overheat and poweroff, so I just ran
everything on my work machine.
You can use the External Tools mechanism to run a short script that syncs your code to the remote server,
runs your script, then syncs back any output files to your local machine. My script looks like this,
is stored in $HOME/bin/runremote.sh, and is executable (chmod +x runremote.sh)
fp="$1" # Local path to the script we want to run--for now,
# this is the only command I pass in from Eclipse, but you could add others if so inclined.
# My home directory is a little different on my local machine than on the remote,
# but otherwise things are in the same place. Adjust as needed.
fp=`python -c "print '$fp'.replace('/home/tsbertalan', '/home/oakridge/bertalan')"`
# Run the synchronization. I use Unison, but you could use something else,
# like two calls to rsync, or a series of scp commands.
reposync >/dev/null # The redirection assumes your sync command will print errors properly on stderr.
cd='cd '`dirname $fp`
# I use a virtual environment on the remote server, since I don't have root access to install
# packages globally. But this could be any set-up command you want to run on the remote.
# A good alternative would be `source $HOME/.profile` or `~/.bashrc`.
act='source /home/oakridge/bertalan/bin/activate'
fname="`basename $fp`"
cmd="$act ; $cd ; python $fname"
# Run the command remotely. The -X forwards X11 windows, so you can see your Matplotlib plots.
# One difficulty with this method is that you might not see all your output just as it is created.
ssh bertalan#remote.server.edu -X "$cmd"
sleep 1
# My synchronization script is bidirectional, but you could just use rsync with the arguments flipped.
reposync >/dev/null
If you don't use linux or OSX locally, you'll probably have to use MinGW or Cygwin or whatever to get
this working. Or, since you appear to have a working Python interpreter, you could write an
equivalent script in Python, make it executable (by the file properties dialog in Explorer, I think),
and add a #!/path/to/python line at the top. I don't use Windows regularly, so I can't really help with that.
To use this in Eclipse, go to Run > External Tools > External Tools Configurations.... Add a new tools
whose Location is the path to your script, and whose first Argument is ${resource_loc}.
You can then use it with Run > External Tools > [first item], or bind it to a keyboard shortcut (I used F12)
by going to Windows > Preferences > Keys, and searching for "Run Last Launched External Tool". Presumably you'll
have to go through the menus first to make this the "Last Launched" external tool.