gcv / julia-snail

An Emacs development environment for Julia
GNU General Public License v3.0
231 stars 21 forks source link

Network IO broken in Julia 1.8.x #120

Closed gcv closed 1 year ago

gcv commented 1 year ago

Picking up from https://github.com/gcv/julia-snail/issues/54#issuecomment-1518170908 ...

@danielmatz: Can you try this branch? https://github.com/gcv/julia-snail/tree/attempt-io-fix — There are no Elisp changes, so if Git package installation is difficult in your environment, you can just grab the JuliaSnail.jl file and overwrite it wherever Snail is installed. I made a couple of small changes in an attempt to improve network IO robustness that seem to work for me locally, but I'm not exactly a remote REPL power user.

gcv commented 1 year ago

To clarify, please test with both Julia 1.8 and 1.7 if possible...

danielmatz commented 1 year ago

1.7.2 continues to work as you described in the debug steps.

For 1.8.4, I no longer get the infinite loop. I can see "hello world" printed out at the REPL. But I don't get the IOError: stream is closed or unusable error. And the nc command doesn't exit until I interrupt it.

gcv commented 1 year ago

So far that’s (new) expected behavior. What about connecting to a remote 1.8.4 instance with Emacs, does that work with the experimental JuliaSnail.el?

danielmatz commented 1 year ago

I can't get snail to connect to a remote instance within Emacs with either 1.8.4 or 1.7.2. I even tried a totally clean config with emacs -Q. With both I get:

Starting Julia process and loading Snail...
if: The vterm buffer is inactive; double-check julia-snail-executable path
danielmatz commented 1 year ago

I tried 1.6.1, and it also doesn't work.

I can try bisecting on julia-snail versions tomorrow.

gcv commented 1 year ago

Please confirm that julia-snail-executable is set to something that should work. And that vterm works correctly aside from Snail.

danielmatz commented 1 year ago

Yes, I'm setting julia-snail-executable in order to try Julia 1.6.1, 1.7.2, and 1.8.4.

Yes, vterm works correctly otherwise.

I tried a few different versions of snail. I wasn't able to find one that worked, but I did notice something you fixed on your attempt-io-fix branch. On version 1.2.0 of snail, it isn't copying over the files to the remote host successfully:

Copying /Users/dmatz/.emacs.d/straight/build/julia-snail/JuliaSnail.jl to /scpx:fsl:/tmp/julia-snail-ee753ddc21b68d9039842e15ab29ad7b450eb2292303d1cacba96af866b3faec/JuliaSnail.jl...failed
tramp-error: Selecting deleted buffer

This only happens the first time you try. From that point on, it seems that snail sees that the /tmp/julia-snail-* directory exists, and so it doesn't try to copy anything, which I assume leads it to fail when it tries to run JuliaSnail.jl.

On your attempt-io-fix branch, everything copies over properly, but I still get:

Starting Julia process and loading Snail...
julia-snail--repl-enable: The vterm buffer is inactive; double-check julia-snail-executable path
gcv commented 1 year ago

It looks like launching the remote REPL dies right away. I can't reproduce it on my system.

When you open a Julia source buffer on the remote host using Tramp, you should be able to examine the value returned from this function: (julia-snail--launch-command). The easiest way to look at it is to go into a remote Julia file, add a comment somewhere that contains the expression, like this:

# This is a remote Julia source file. It's opened from the local Emacs instance using Tramp.
# (julia-snail--launch-command)

Place the cursor after the closing parenthesis, and press C-u C-x C-e. That should insert an ssh command, like this:

# (julia-snail--launch-command) "ssh -t -L 10199:localhost:10199 remotehost /home/cv/julia-1.8.5/bin/julia --project=~/myproject -L /tmp/julia-snail-c41a6703d3a802996d2aca8ce6dc5ef057f0c7136e5feacb8b131c449b7ba51f/JuliaSnail.jl"

Now take that string, and paste it into a local shell. It should bring up a remote REPL. Does it do so? If it errors out, what's the error?

danielmatz commented 1 year ago

Ah hah! When I run (julia-snail--launch-command), I get nil! Looking at the source, I see that you are checking for the TRAMP connection method to be "ssh", but I typically use "scpx".

See https://www.gnu.org/software/tramp/#Inline-methods and the following section on external methods. There are quite a few variations on using ssh. Perhaps you should be checking for the method to be one of ssh, sshx, rsync, scp, or scpx?

I tested with the ssh method, and I was able to launch a snail repl!

gcv commented 1 year ago

Nice catch! I just pushed a change to the attempt-to-fix branch that adds scp and scpx connection methods. Could you test it please?

danielmatz commented 1 year ago

Seems like it is working!

gcv commented 1 year ago

Great. Normally, I'd let something like this sit in master for a few weeks, but these are important enough bugfixes that I also tagged a version 1.2.1 release. Thanks for helping track these down.

kadir-gunel commented 11 months ago

Hello @gcv , I am struggling to connect tramp via ssh but I can do sshx without any problems. I searched and configured ton of stuff. And no hope with ssh. I saw above that you added scp and scpx. Is it possible for you to add sshx as well ? Or are there any problems with sshx ?

B.R.