Closed norci closed 2 years ago
Running Julia in-container isn't a use case Snail supports at the moment, but I applaud your attempt. :) I expect a number of things to break, including xref, because absolute file paths to Julia source code won't be the same in Emacs and in-container. Remote REPL over SSH should work, but of course you'll have to set up ssh on the container and edit code over Tramp even if it's mounted from a volume.
That said, the basic network connection seems like it should work based on your port mapping. What happens if you just try to access the socket on the Julia side? Command line:
echo '(reqid = "abcd1234", ns = [:Main], code = "println(\"hello world\")")' | nc localhost 10011
If that doesn't work, you have connectivity problems from your machine to the container.
thanks for your help. The network issue has been fixed in #66.
how to update julia-snail.el
, so we can customize julia-snail--launch-command
and listen address?
1 file changed, 2 insertions(+), 22 deletions(-)
julia-snail.el | 24 ++----------------------
modified julia-snail.el
@@ -399,27 +399,7 @@ Returns nil if the poll timed out, t otherwise."
snail-remote-dir))
(defun julia-snail--launch-command ()
+ "docker-compose --project-directory=/x run --rm -v ~/.emacs.d/julia-snail/:/julia-snail -e 10011 -p 127.0.0.1:10011:10011 julia julia -L /julia-snail/JuliaSnail.jl")
(defun julia-snail--efn (path &optional starting-dir)
"A variant of expand-file-name that (1) just does
@@ -492,7 +472,7 @@ returns \"/home/username/file.jl\"."
(user-error "The vterm buffer is inactive; double-check julia-snail-executable path"))
;; now try to send the Snail startup command
(julia-snail--send-to-repl
- (format "JuliaSnail.start(%d); # please wait, time-to-first-plot..." (or julia-snail-remote-port julia-snail-port))
+ (format "JuliaSnail.start(%d; addr=\"%s\"); # please wait, time-to-first-plot..." (or julia-snail-remote-port julia-snail-port) "0.0.0.0")
:repl-buf repl-buf
;; wait a while in case dependencies need to be downloaded
:polling-timeout (* 5 60 1000)
The right approach is probably to add a new defcustom
like julia-snail-container-params
or something, have it be a real data structure like an alist with parameters, recognize that it's set in julia-snail--launch-command
, and construct an appropriate launch command. It needs to be flexible to recognize different container use cases.
After you solved the network problem and made the Emacs and Julia sides of Snail start talking to each other, how much of Snail actually worked?
To make julia-snail-send-buffer-file
work, you need to do path mapping from local to remote volume paths (hacking julia-snail--efn
is probably necessary), and to make other julia-snail-send-*
functions work, you'd need to do something with julia-snail--send-to-server-via-tmp-file
because temporary files will be Emacs-local, not container-local. That might be fixable by rebinding Emacs's idea of the temporary directory root to be in-container, along with another volume mapping.
Proper xref support will require its own path translation changes, I think. Not sure without investigating.
How much of this do you want to take on? :) Container support is a good feature to add, but I don't have time to do much more than give suggestions and review code.
Thinking about this some more: julia-snail-container-params
maybe should be julia-snail-container-conf
, and can contain configuration parameters for path mapping (path-root-local
, path-root-container
, that sort of thing). The stuff relying on tmp will be trickier, since it’ll require a local temporary directory which isn’t necessarily the same as local $TMPDIR
. Not sure at the moment how to keep that from polluting the user’s local disk.
Discussion in #66.
I want to run julia inside a docker container, in my local machine. so I changed julia-snail--launch-command to
the command
julia-snail-send-line
works. But all the other functions do not work. e.g.Could you have a look? thanks