Drive java / kulla from pexpect? (Context: Jupyter) - jupyter

I am trying to use the java_kernel for jupyter (https://github.com/Bachmann1234/java9_kernel and issue 24 therein). It works fine on a Mac OSX box. But on Linux (debian), the Java shell is not starting up.
I think I tracked it down to a call like this one:
ptyprocess.PtyProcess.spawn(["/home/jupyterhub/java/jdk-9/bin/java", "-jar", "/home/jupyterhub/java/kulla/kulla.jar"])
Reading pexpect code (https://github.com/pexpect/ptyprocess/blob/master/ptyprocess/ptyprocess.py), I would expect to end up in an exec call, having the child process running python replaced by java. However, this does not happen, ps -fu shows a python child process.
I'm guessing there is some subtle difference between pty handling on linux and osx that causes the differences here?
java-9/jshell as such work from the command line.
Any help much appreciated!
Best,
Holger

There seems to be a change in the way that later versions of jdk-9 deal with terminals on Linux. I reverted to jdk-9.ea+100 and that seems to work.

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."

VSCode and cortex-debug plugin is sometimes really slow on QEMU target - but only on Windows OS

we have created an assembler project for Cortex A9 that we would like to prepare the code for without the board. We, therefore, chose to use cortex-debug plugin and it seems that every 2-5 instructions, it takes over a second or two to get to the next step.
It seems that it happens during the "data-list-register-values" command issued to QEMU.
It works ok if I run same command from command line in GDB and also on Linux we didn't spot this problem. It happens only on windows and it seems only under VSCode.
Any advice or more info on this strange behaviour?
Thanks in advance,
regards.

python interpreter citing zen of python in the terminal window

I run vscode version 1.65.2.
Today it started citing the whole "The Zen of Python" in the terminal window every time I run a python script in the debugger.
EDIT: It turns out that it is the python interpreter that does it, not vscode. The problem apparently came after I updated ipykernel to version 6.11.0. I run python version 3.9.1 on Windows.
How can I turn it off?
I havent been able to find an answer to this anywhere.
It turned out that an import statement had found its way into my code: "import this as d", and removing it solved the problem. It is a mystery how it ended up there, I certainly haven't put it there knowingly. But problem solved!
That's really odd. I just had the exact same thing. Even the import this as d was on the first line before everything. I use vscode as well. Removing it does help. But I didn't update a kernel prior to this. It happened while I was writing code I think. Python 3.8.10 on Linux.

Can you take terminal commands and use them in a Python program?

In another thread, there is an excellent step by step to completely uninstall VSCode off my Mac so I could truly start over. The steps work perfectly. In my question to try a lot of configurations and extensions, I mess up VSCode pretty often.
Is there a way to build Python file so when I need to uninstall, I can open a terminal window and run a program and be ready to try again? It is not the end of the world to have to type one line at a time, I'm just assuming this is common and been fixed. I'm just not able to find the how.
After doing some studying of Python, I found the OS module. Once you import it, most, if not all the commands to clean up directories, delete files, etc. are in there. I took the list of commands that ran in a ZSH terminal and converted them to os.[relevantcommand] and it worked fine. Now, I can easily clean out a VSCode install by running my VSCleanup.py and start over.

Spawning child processes returns invalid argument

I have a class this semester that requires a lisp dialect so I'm trying to get started with Clojure but I'm running into a lot of problems setting up my environment.
I'm on a Windows machine and am following the tutorial at http://www.braveclojure.com/basic-emacs/ to set up emacs which from my research seems like the best IDE for working with lisp. I had Cygwin installed before starting which supposedly has a lot of support for emacs but I'm not sure if I need to do more than just have it installed.
My problems is when I try to start a REPL in emacs with M-x cider-jack-in I get the response Spawning child process: invalid argument. If I do the M-x load-path command I get a list of every subfolder in my .emacs.d folder but not the .d folder itself but the folder where my cider package is installed is clearly listed.
I installed lein before I decided to try setting up emacs and I could open a REPL just fine with it but emacs seems like a much better way of working than just using the terminal.
Any advice is greatly appreciated but if there is a better/easier way to get started with Clojure on Windows than what I'm currently doing I'd love to hear about it.
Thanks in advance for any replies.
Yes, emacs is great, but if you haven't worked with it before then you will have a very steep learning curve, exacerbated by the fact you are running Windows. I myself use emacs with CIDER a lot, and I also use emacs on Windows quite a bit, but I don't mix it - I use emacs/CIDER only on Linux. It doesn't mean at all that it can't be made to work on Windows, it's just it has a lot of complexity of its own, which you might not have time or inclination to deal with right now. (By the way, I wouldn't recommend using emacs under Cygwin [1] , use a good native build instead. And if you still decide to go with emacs, by all means try Prelude - it comes from the author of CIDER by the way.)
If you want an option that is definitely smoother under the circumstances, download IntelliJ IDEA Community Edition and install Cursive. That will have its own learning curve for sure, but give it a try and see what you prefer. I use both, nothing beats IntelliJ/Cursive in Java interop projects.
Both emacs/CIDER and IntelliJ/Cursive are terrific and will repay for deeper learning.
[1] I am not even sure a combination of emacs on Cygwin and lein/clojure on Win32 can work, but I have no environment to test.
unset the SHELL env variable - taken from: http://tb-nguyen.blogspot.com/2010/05/how-to-fix-emacs-windows-error-spawning.html
It worked for me