0

I try to use julia-1.6 with VScode, but I cannot find a path to the executable. When I try to change the working directory via the julia prompt to the executable, I get an error message saying it's not a directory:

julia> cd("/Users/jjdegruijter/bin/julia")

Can anybody tell how to do it properly?

phipsgabler
  • 20,535
  • 4
  • 40
  • 60
JdG
  • 19
  • 4
  • Don't you want `cd("/Users/jjdegruijter/bin/")` instead? `/Users/jjdegruijter/bin/julia` is the actual binary and not a directory. – pfitzseb Feb 04 '22 at 11:58

1 Answers1

2

To get the path to your Julia executable, from the REPL, do:

joinpath(Sys.BINDIR, "julia")

You can start a REPL by just running julia from the terminal, or by pressing Alt-J Alt-O in VS Code (you can also instead type Ctrl-Shift-P, then choose Julia: Start REPL from that list).

Or, you can also directly run the above command from the terminal without starting a REPL: julia -e 'println(joinpath(Sys.BINDIR, "julia"))'.

If you just want to change working directory to the directory containing the executable (though I'm not sure why you'd want that here):

cd(Sys.BINDIR)
Sundar R
  • 13,776
  • 6
  • 49
  • 76
  • I do not know how to start REPL. When I put joinpath... in my terminal I get syntaxerror unexpected token 'Sys.BINDIR,'. – JdG Feb 06 '22 at 13:43
  • You mention typing `cd("/Users/jjdegruijter/bin/julia")` at a `julia> ` prompt in the question. Wherever you get that `julia> ` prompt, that's an REPL. – Sundar R Feb 06 '22 at 14:57
  • Or from the terminal, you can try running `julia -e 'println(joinpath(Sys.BINDIR, "julia"))'`. – Sundar R Feb 06 '22 at 14:58
  • I've added in instructions about accessing the REPL to the answer, please take a look. – Sundar R Feb 06 '22 at 15:08
  • When I run "julia -e ...." from the terminal, then I get " julia: command not found" – JdG Feb 07 '22 at 15:28
  • My problem is that my setting to the julia executable path in VScode still does not work. The last version I tried is: "julia.executablePath": "/Applications/julia-1.6.app/Contents/Resources/julia – JdG Feb 07 '22 at 15:51
  • @JdG You mention "the julia prompt" in the question. How did you get that? – Sundar R Feb 07 '22 at 17:15
  • I got the julia prompt by clicking on the julia executable in the bin. – JdG Feb 08 '22 at 06:39
  • Are you able to click on the julia executable again and get the prompt? If so, please do that and then run the `joinpath` command given in the answer. If for some reason you're not able to do that, [we can discuss this further in chat](https://chat.stackoverflow.com/rooms/241837/q-70985429). – Sundar R Feb 08 '22 at 20:22
  • I've run the joinpath command, and put the path that was returned by the prompt in the VScode setting. It didn't help. I got "Could not start the Julia language server. Make sure the configuration setting julia.executablePath points to the Julia binary." – JdG Feb 09 '22 at 11:16
  • Fyi I work with OS version 10.11.6 – JdG Feb 09 '22 at 11:19
  • You might have luck setting `PATH` to have the Julia path (the `Sys.BINDIR` result alone, without the `"julia"` at the end); see [this answer for an example of modifying `PATH`](https://stackoverflow.com/a/26586170/8127). After setting that, delete the `executablePath` setting you added, restart the system, and try VSCode again. But at this point I suspect something may have gone wrong with your VS Code Julia extension installation itself. If the above doesn't work, please ask this question on the [Julia Discourse](https://discourse.julialang.org/) with screenshots and version information. – Sundar R Feb 09 '22 at 22:51