# Remote development using VSCode tip

**URL:** <https://discourse.julialang.org/t/remote-development-using-vscode-tip/60522>\
**Category:** VS Code\
**Created:** [May 4, 2021, 2:29pm UTC](https://discourse.julialang.org/t/remote-development-using-vscode-tip/60522 "2021-05-04T14:29:22Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmair](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmair/32/35117_2.png) [@jmair](https://discourse.julialang.org/u/jmair)\
**Post date:** [May 4, 2021, 2:29pm UTC](https://discourse.julialang.org/t/remote-development-using-vscode-tip/60522/1 "2021-05-04T14:29:22Z")

</div>

I am currently using a HPC to work on my Julia code. I normally use VS Code and the remote development tools to SSH into the HPC, however, I have had some issues with the Julia intellisense when on a remote system.

I have managed to get this working and wanted to share the steps here in case anyone else has the same issue.

The first problem is that the julia install has to be loaded using a “module load” command. Fortunately, you can bundle all of your commands into one file (I have called mine start\_julia.sh):

```julia
#!/bin/bash

module load <INSERT MODULE PATH HERE>

julia --project=<INSERT PROJECT WORKING DIR HERE> -t 2 -e "using LanguageServer, LanguageServer.SymbolServer; runserver()" &
julia "$@"

```

I gave this file execution permissions with “chmod +x start\_julia.sh”, and set the Julia environment path in the Julia extension settings to " ${workspaceFolder}/start\_julia.sh". This seemed to work and now I have intellisense while editing files during remote development. Unfortunately, the inbuilt “Start REPL” command doesn’t seem to work, but I can work fine without it.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [May 4, 2021, 2:33pm UTC](https://discourse.julialang.org/t/remote-development-using-vscode-tip/60522/2 "2021-05-04T14:33:46Z")

</div>

That first Julia invocation should be unnecessary. Also, `julia.executablePath` should point towards your script, not `julia.environmentPath`.

---

<div class="post-metadata">

**Author:** ![jmair](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmair/32/35117_2.png) [@jmair](https://discourse.julialang.org/u/jmair)\
**Post date:** [May 4, 2021, 2:56pm UTC](https://discourse.julialang.org/t/remote-development-using-vscode-tip/60522/3 "2021-05-04T14:56:04Z")

</div>

My mistake, I meant to write “executable” path instead. However, the language server failed to start without explicitly starting it before. This was the only way it managed to run. This may be due to how Julia was installed on the system, but I have no control over this.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [May 4, 2021, 2:57pm UTC](https://discourse.julialang.org/t/remote-development-using-vscode-tip/60522/4 "2021-05-04T14:57:24Z")

</div>

You might be able to get some more info on what’s going on by navigating to `Output` \> `Julia Language Server`.

---

<div class="post-metadata">

**Author:** ![jmair](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmair/32/35117_2.png) [@jmair](https://discourse.julialang.org/u/jmair)\
**Post date:** [May 4, 2021, 3:15pm UTC](https://discourse.julialang.org/t/remote-development-using-vscode-tip/60522/5 "2021-05-04T15:15:29Z")

</div>

When setting the `julia.executablePath` to my julia executable, the julia language plugin crashes, and gives the following output:

```julia
┌ Warning: Some Julia code in the VS Code extension crashed with
│ e = InvalidStateException("Channel is closed.", :closed)
└ @ Main ~/.vscode-server/extensions/julialang.language-julia-1.1.38/scripts/error_handler.jl:5
ERROR: InvalidStateException("Channel is closed.", :closed)
Stacktrace:
 [1] try_yieldto(undo::typeof(Base.ensure_rescheduled))
   @ Base ./task.jl:705
 [2] wait
   @ ./task.jl:764 [inlined]
 [3] wait(c::Base.GenericCondition{ReentrantLock})
   @ Base ./condition.jl:106
 [4] take_buffered(c::Channel{Any})
   @ Base ./channels.jl:389
 [5] take!
   @ ./channels.jl:383 [inlined]
 [6] get_next_message(endpoint::JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint})
   @ JSONRPC ~/.vscode-server/extensions/julialang.language-julia-1.1.38/scripts/packages/JSONRPC/src/core.jl:197
 [7] macro expansion
   @ ~/.vscode-server/extensions/julialang.language-julia-1.1.38/scripts/packages/LanguageServer/src/languageserverinstance.jl:263 [inlined]
 [8] (::LanguageServer.var"#98#100"{LanguageServerInstance})()
   @ LanguageServer ./task.jl:406

```

When removing the explicit running of the language server, as posted originally, I get a different error, with the server crashing:

```julia
[Error - 4:06:12 PM] Starting client failed
Error: Unsupported server configuration {
    "run": {
        "command": null,
        "args": [
            "--startup-file=no",
            "--history-file=no",
            "--depwarn=no",
            "--project=/gpfs01/home/user/.vscode-server/extensions/julialang.language-julia-1.1.38/scripts/environments/languageserver",
            "main.jl",
            "/gpfs01/home/user/dev/julia/HPC",
            "--debug=no",
            "/tmp/vsc-jl-cr-552dc18e-d1cf-43c9-acbe-97cd49de6433",
            "",
            "/gpfs01/home/user/.vscode-server/data/User/globalStorage/julialang.language-julia"
        ],
        "options": {
            "cwd": "/gpfs01/home/user/.vscode-server/extensions/julialang.language-julia-1.1.38/scripts/languageserver",
            "env": {
                "JULIA_DEPOT_PATH": "/gpfs01/home/user/.vscode-server/data/User/globalStorage/julialang.language-julia/lsdepot/v1",
                "JULIA_LOAD_PATH": ":",
                "HOME": "/gpfs01/home/user",
                "JULIA_LANGUAGESERVER": "1"
            }
        }
    },
    "debug": {
        "command": null,
        "args": [
            "--startup-file=no",
            "--history-file=no",
            "--depwarn=no",
            "--project=/gpfs01/home/user/.vscode-server/extensions/julialang.language-julia-1.1.38/scripts/environments/languageserver",
            "main.jl",
            "/gpfs01/home/user/dev/julia/HPC",
            "--debug=yes",
            "/tmp/vsc-jl-cr-552dc18e-d1cf-43c9-acbe-97cd49de6433",
            "",
            "/gpfs01/home/user/.vscode-server/data/User/globalStorage/julialang.language-julia"
        ],
        "options": {
            "cwd": "/gpfs01/home/user/.vscode-server/extensions/julialang.language-julia-1.1.38/scripts/languageserver",
            "env": {
                "JULIA_DEPOT_PATH": "/gpfs01/home/user/.vscode-server/data/User/globalStorage/julialang.language-julia/lsdepot/v1",
                "JULIA_LOAD_PATH": ":",
                "HOME": "/gpfs01/home/user",
                "JULIA_LANGUAGESERVER": "1"
            }
        }
    }
}
	at /gpfs01/home/user/.vscode-server/extensions/julialang.language-julia-1.1.38/dist/extension.js:7:56727

```

---

<div class="post-metadata">

**Author:** ![haberdashPI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/haberdashpi/32/26337_2.png) [@haberdashPI](https://discourse.julialang.org/u/haberdashPI)\
**Post date:** [May 5, 2021, 4:06pm UTC](https://discourse.julialang.org/t/remote-development-using-vscode-tip/60522/6 "2021-05-05T16:06:07Z")

</div>

I’m having a similar problem to @jmair. I think, if I get the below to work, it would also solve their problems.

I’m trying to get the executable path for julia using [asdf](https://asdf-vm.com/#/). Here’s my zsh script.

```nohighlight
#! /usr/bin/zsh
source ~/.zshrc
julia_exec=`asdf env julia which julia`
echo "${@:q}" > $HOME/debug.txt
$julia_exec "${@:q}"

```

This script is saved as `~/Documents/preferences/julia_remote.sh` and this is what I set `julia.executablePath` to.

And here’s the output of `debug.txt` (with spaces replaced with line breaks for readability) after starting a REPL.

```julia
-i 
--banner=no 
--project=/home/davidlittle/Documents/work/projects/german_track 
/home/davidlittle/.vscode-server/extensions/julialang.language-julia-1.1.38/scripts/terminalserver/terminalserver.jl 
/tmp/vsc-jl-repl-6ba95a18-2b77-470c-955e-8b24f9084815 
/tmp/vsc-jl-cr-eb8996c6-6e9c-4254-a1ff-a984db1706d1 
USE_REVISE=true 
USE_PLOTPANE=true 
USE_PROGRESS=true 
DEBUG_MODE=undefined

```

This _almost_ works. The language server successfully starts, and the command to start a REPL appears to work.

However, when I try to send code to the REPL, that command appears to be completely ignored.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [May 5, 2021, 4:18pm UTC](https://discourse.julialang.org/t/remote-development-using-vscode-tip/60522/7 "2021-05-05T16:18:23Z")

</div>

Can you check the Julia Language Server and Julia Language Server trace outputs? There are (at least) two possible failure modes here: Either the LS is stuck or the REPL process doesn’t connect to the pipe properly.

---

<div class="post-metadata">

**Author:** ![haberdashPI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/haberdashpi/32/26337_2.png) [@haberdashPI](https://discourse.julialang.org/u/haberdashPI)\
**Post date:** [May 5, 2021, 6:43pm UTC](https://discourse.julialang.org/t/remote-development-using-vscode-tip/60522/8 "2021-05-05T18:43:48Z")

</div>

Odd… my problem seems to have just “disappeared”. I just tried it again to get your requested outputs and everything just “worked”.

For what it’s worth, I did check the Language server trace and output earlier, when I was having an issue. Both suggested the language server was up and running, so the issue appeared to be a problem connecting to the pipe.

I haven’t used the REPL much (I tend to use my own, separate setup for REPL-age, in part because I haven’t bothered to figure this issue around asdf out), do you have to wait for the language server to be up and running before sending things to the REPL works? If so, that was probably the issue I was having.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [May 6, 2021, 7:27am UTC](https://discourse.julialang.org/t/remote-development-using-vscode-tip/60522/9 "2021-05-06T07:27:48Z")

</div>

> [@haberdashPI](#):
>
> I haven’t used the REPL much (I tend to use my own, separate setup for REPL-age, in part because I haven’t bothered to figure this issue around asdf out), do you have to wait for the language server to be up and running before sending things to the REPL works? If so, that was probably the issue I was having.

Yes. There’s also a bug where indexing can sometimes block other LS requests, which frequently results in issues like the one you were seeing.

---

<div class="post-metadata">

**Author:** ![haberdashPI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/haberdashpi/32/26337_2.png) [@haberdashPI](https://discourse.julialang.org/u/haberdashPI)\
**Post date:** [May 6, 2021, 4:12pm UTC](https://discourse.julialang.org/t/remote-development-using-vscode-tip/60522/10 "2021-05-06T16:12:46Z")

</div>

Great, thanks, I think this is mostly working for me then.

@jmair Does my script help you solve your problem? I ran into issues when I used `$@` or `"$@"` alone, because one of the arguments to julia can be an empty string, which gets missed if you don’t re-quote the arguments. In zsh you can do `${@:q}` to fix the arguments: I’m not familiar with the analogous bash expansion, so I’m not sure what the equivalent would be there.
