# Remote REPLs with julia-repl in emacs

**URL:** <https://discourse.julialang.org/t/remote-repls-with-julia-repl-in-emacs/36435>\
**Category:** Tooling\
**Tags:** repl, emacs\
**Created:** [March 24, 2020, 11:59am UTC](https://discourse.julialang.org/t/remote-repls-with-julia-repl-in-emacs/36435 "2020-03-24T11:59:31Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![atteson](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@atteson](https://discourse.julialang.org/u/atteson)\
**Post date:** [March 24, 2020, 11:59am UTC](https://discourse.julialang.org/t/remote-repls-with-julia-repl-in-emacs/36435/1 "2020-03-24T11:59:31Z")

</div>

I’m having difficulty using julia-repl to run a remote REPL with tramp in emacs. I like julia-repl better than ESS because it uses the emacs term which allows use of the package manager, etc. in the REPL. However, it seems that julia-repl uses the emacs function make-term which uses start-process (instead of start-file-process) which, it seems, doesn’t allow one to change the default-directory variable. Has anyone managed to solve this?

I don’t see an easy way to change julia-repl to fix this. I think the emacs builtin file term.el would have to change.

---

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [March 24, 2020, 12:33pm UTC](https://discourse.julialang.org/t/remote-repls-with-julia-repl-in-emacs/36435/2 "2020-03-24T12:33:27Z")

</div>

See [this issue for `julia-repl`](https://github.com/tpapp/julia-repl/issues/61) which suggests it’s not currently possible. If any comint-based solution works fine for you and you don’t mind some un-anchored elisp code floating around, you could use the [`inferior-julia` improvements I hacked together](https://github.com/JuliaEditorSupport/julia-emacs/pull/106) (I plan to clean it up and package it eventually); it has support for package manager, help, and shell modes.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 24, 2020, 2:40pm UTC](https://discourse.julialang.org/t/remote-repls-with-julia-repl-in-emacs/36435/3 "2020-03-24T14:40:03Z")

</div>

This should actually be possible via ssh, I just need to think about how to implement this nicely.

---

<div class="post-metadata">

**Author:** ![atteson](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@atteson](https://discourse.julialang.org/u/atteson)\
**Post date:** [March 24, 2020, 5:35pm UTC](https://discourse.julialang.org/t/remote-repls-with-julia-repl-in-emacs/36435/4 "2020-03-24T17:35:56Z")

</div>

The solution, thanks to tkluck on another thread I posted about fixing the issue for ssh, is to use the “-t” option. This works well:

```julia
(make-term "test" "ssh" nil "-t" "user@hostname" "julia")

```

I’m going to wrap that in some simple clothes use it for now.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 25, 2020, 12:18pm UTC](https://discourse.julialang.org/t/remote-repls-with-julia-repl-in-emacs/36435/5 "2020-03-25T12:18:20Z")

</div>

Yes, eventually I plan to make `ssh` work nice with `julia-repl`; it’s just that at the moment I am focusing on integrating `libvterm`. Making a terminal is actuallly trivial; `ssh` takes the place of the Julia executable and then the arguments are just appended to the command line.

It’s the user interface that is the tricky part and I want to think a bit about making that robust, so that one can reattach to an existing process (`tmux`, `screen`).

---

<div class="post-metadata">

**Author:** ![danielw2904](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielw2904/32/10890_2.png) [@danielw2904](https://discourse.julialang.org/u/danielw2904)\
**Post date:** [May 1, 2020, 12:15pm UTC](https://discourse.julialang.org/t/remote-repls-with-julia-repl-in-emacs/36435/6 "2020-05-01T12:15:11Z")

</div>

I’ve been using [`dtach`](https://linux.die.net/man/1/dtach) with R processes for a similar setup. I open the file via `TRAMP`, start a shell, reattach the process and run `ess-remote`. I’m sure this can somehow be automated in emacs lisp but I’m terrible at that. If someone could point me in the right direction I could try to put something together for `julia-repl`.

---

<div class="post-metadata">

**Author:** ![orialb](https://avatars.discourse-cdn.com/v4/letter/o/65b543/32.png) [@orialb](https://discourse.julialang.org/u/orialb)\
**Post date:** [May 1, 2020, 12:30pm UTC](https://discourse.julialang.org/t/remote-repls-with-julia-repl-in-emacs/36435/7 "2020-05-01T12:30:11Z")

</div>

I’ve been experimenting recently with adding remote support to [julia-snail](https://github.com/gcv/julia-snail) (see discussion [here](https://github.com/gcv/julia-snail/issues/26) ).

I have been using the code in this [branch](https://github.com/orialb/julia-snail/tree/remote) (on my fork, it is not part of julia-snail yet) for the last week and it has been working quite well so far. In addition to the REPL one can get code completion when working on the remote TRAMP files.  
It is all still experimental and rough, the code can definitely be improved and cleaned, but it is already usable for real work for me. If anyone wants to give it a try I’m happy to add some explanation of how to set it up.

---

<div class="post-metadata">

**Author:** ![andrewsteck](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrewsteck/32/1876_2.png) [@andrewsteck](https://discourse.julialang.org/u/andrewsteck)\
**Post date:** [June 5, 2020, 8:11pm UTC](https://discourse.julialang.org/t/remote-repls-with-julia-repl-in-emacs/36435/8 "2020-06-05T20:11:31Z")

</div>

I’m working on getting a similar setup working – is there anyway you can elaborate on where this line goes/what it means for someone just getting into emacs (but familiar with ssh etc.)?

---

<div class="post-metadata">

**Author:** ![atteson](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@atteson](https://discourse.julialang.org/u/atteson)\
**Post date:** [June 5, 2020, 9:14pm UTC](https://discourse.julialang.org/t/remote-repls-with-julia-repl-in-emacs/36435/9 "2020-06-05T21:14:36Z")

</div>

Unfortunately, I ended up going a different direction. I can’t remember if that worked for me or not.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [June 7, 2020, 12:32pm UTC](https://discourse.julialang.org/t/remote-repls-with-julia-repl-in-emacs/36435/10 "2020-06-07T12:32:50Z")

</div>

Basically,

1. set up passwordless remote login on `somehost` with the Julia executable available at `/path/julia`,
2. make sure that from the command line (outside Emacs)

```nohighlight
ssh -t somehost /path/julia

```

works,
3. add an [executable record](https://github.com/tpapp/julia-repl/#julia-executables) as

```nohighlight
(remote "ssh -t somehost /path/julia")

```

and select it.

I will add it to the README at some point.

---

<div class="post-metadata">

**Author:** ![andrewsteck](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrewsteck/32/1876_2.png) [@andrewsteck](https://discourse.julialang.org/u/andrewsteck)\
**Post date:** [June 8, 2020, 3:18pm UTC](https://discourse.julialang.org/t/remote-repls-with-julia-repl-in-emacs/36435/11 "2020-06-08T15:18:44Z")

</div>

Thanks Tamas – it was #3 that was my hangup, but I don’t know why it didn’t occur to treat this as running a different executable (eg version of julia). I’ll give this a try!

---

<div class="post-metadata">

**Author:** ![andrewsteck](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrewsteck/32/1876_2.png) [@andrewsteck](https://discourse.julialang.org/u/andrewsteck)\
**Post date:** [June 8, 2020, 5:49pm UTC](https://discourse.julialang.org/t/remote-repls-with-julia-repl-in-emacs/36435/12 "2020-06-08T17:49:02Z")

</div>

Somehow it looks like this isn’t quite parsing correctly. I’m getting an error like:

```julia
..: line 0: [: too many arguments
..: /path/to/juliafile/ssh -t somehost /path/julia: No such file or directory
..: line 0: exec: /path/to/juliafile/ssh -t somehost /path/julia: cannot execute: No such file or directory

Process julia-remote exited abnormally with code 126

```

I’ve also made sure to confirm that other executable records are working properly on my local machine, as described in the docs. Any advice would be appreciated!

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [June 9, 2020, 7:46am UTC](https://discourse.julialang.org/t/remote-repls-with-julia-repl-in-emacs/36435/13 "2020-06-09T07:46:24Z")

</div>

I think that will be the `make-term` calling convention — I will look into it later; please kindly open an issue so that it does not get lost.

In the meantime, you can also try the experimental vterm backend:

> <https://github.com/tpapp/julia-repl/pull/84>
>
> Factor out code interacting with the terminal using generic functions.
> 
> Add ba…ckend code for \[emacs-libvterm\](https://github.com/akermu/emacs-libvterm).
> 
> Disables byte compilation do get conditional code to work.

which should work.
