I can’t get the console to find the code executable:
C:\Users\necka>code #works as expected
C:\Users\necka>julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.3.0-rc2.0 (2019-09-12)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
shell> code
ERROR: IOError: could not spawn `code`: no such file or directory (ENOENT)
Stacktrace:
[1] _spawn_primitive(::String, ::Cmd, ::Array{Any,1}) at .\process.jl:99
[2] setup_stdios(::Base.var"##558#559"{Cmd}, ::Array{Any,1}) at .\process.jl:112
[3] _spawn at .\process.jl:111 [inlined]
[4] #run#569(::Bool, ::typeof(run), ::Cmd) at .\process.jl:439
[5] run at .\process.jl:438 [inlined]
[6] repl_cmd(::Cmd, ::REPL.Terminals.TTYTerminal) at .\client.jl:77
[7] top-level scope at none:0
As you can see it cannot find the executable for vscode. I need it to be able to enable @edit to open the editor with the correct line information. Right now line information is not passed even though vscode is opened.
julia> ENV["JULIA_EDITOR"]=replace(raw"C:\Users\necka\AppData\Local\Programs\Microsoft VS Code\bin\code.cmd", "\\"=>"/")
"C:/Users/necka/AppData/Local/Programs/Microsoft VS Code/bin/code.cmd"
julia> @edit println(5)
ERROR: IOError: could not spawn `C:/Users/necka/AppData/Local/Programs/Microsoft VS Code/bin/code.cmd 'E:\Programme\Julia\bin\..\share\julia\base\coreio.jl'`: no such file or directory (ENOENT)
Stacktrace:
[1] _spawn_primitive(::String, ::Cmd, ::Array{Any,1}) at .\process.jl:99
[2] setup_stdios(::Base.var"##558#559"{Cmd}, ::Array{Any,1}) at .\process.jl:112
[3] _spawn at .\process.jl:111 [inlined]
[4] #run#569(::Bool, ::typeof(run), ::Cmd) at .\process.jl:439
[5] run at .\process.jl:438 [inlined]
[6] edit(::String, ::Int32) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\InteractiveUtils\src\editless.jl:80
[7] edit(::Function, ::Any) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\InteractiveUtils\src\editless.jl:102
[8] top-level scope at REPL[17]:1
How about run(`code`)? (Or the corresponding full-path invocation.) If I remember rightly, spawning commands from the “shell” mode on Windows has a spotty record.
Edit a file or directory optionally providing a line number to edit the file at. Return to the julia prompt when you quit the editor. The editor can be changed by setting JULIA_EDITOR , VISUAL or EDITOR as an environment variable.
This solves it! Thanks
Though I hate that the Windows path variable is not considered when looking up executables… Thus I have to precisely say where each executable is that I might need and cannot just depend upon the executables available (on other systems where I have no control over the place).
this works here under Windows 10 and assumes that the path to VSCode is added to the PATH environment. This is an option during installation of VSCode and there is a note that you have to restart the PC.
julia> ENV["PATH"]
"...snippped...;C:\\Users\\oheil\\AppData\\Local\\Programs\\Microsoft VS Code\\bin"
In this path there are two files:
code
code.cmd
where only code.cmd can be started from within julia. If you try code in a windows cmd shell, the extenstions .exe, .cmd and .bat are automatically tested, and as there is code.cmd, this one is executed. Looking into code it is a unix/linux like shell script.
Though I hate that the Windows path variable is not considered when looking up executables… Thus I have to precisely say where each executable is that I might need and cannot just depend upon the executables available (on other systems where I have no control over the place).
So the path variable is actually considered, but my first attempt with code.exe, which is not in the bin folder, created the impression that it is not. @rapus95 can you cross check and change the solution for future solution seekers?