Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edit function doesn't work inside VSCode's Julia REPL #2057

Closed
pgagarinov opened this issue Mar 15, 2021 · 15 comments · Fixed by #2067
Closed

edit function doesn't work inside VSCode's Julia REPL #2057

pgagarinov opened this issue Mar 15, 2021 · 15 comments · Fixed by #2067
Labels

Comments

@pgagarinov
Copy link

pgagarinov commented Mar 15, 2021

When I try to call edit for jl file I get the following error

julia> edit("main.jl")

julia> App threw an error during load
/home/peter/_Git/_Julia/try-weave/main.jl:1
using Plots;
      ^^^^^

SyntaxError: Unexpected identifier
    at wrapSafe (internal/modules/cjs/loader.js:1060:16)
    at Module._compile (internal/modules/cjs/loader.js:1108:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1173:10)
    at Module.load (internal/modules/cjs/loader.js:992:32)
    at Module._load (internal/modules/cjs/loader.js:885:14)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
    at loadApplicationPackage (/usr/lib/electron/resources/default_app.asar/main.js:110:16)
    at Object.<anonymous> (/usr/lib/electron/resources/default_app.asar/main.js:222:9)
    at Module._compile (internal/modules/cjs/loader.js:1152:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1173:10)
A JavaScript error occurred in the main process
Uncaught Exception:
/home/peter/_Git/_Julia/try-weave/main.jl:1
using Plots;
      ^^^^^

SyntaxError: Unexpected identifier
    at wrapSafe (internal/modules/cjs/loader.js:1060:16)
    at Module._compile (internal/modules/cjs/loader.js:1108:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1173:10)
    at Module.load (internal/modules/cjs/loader.js:992:32)
    at Module._load (internal/modules/cjs/loader.js:885:14)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
    at loadApplicationPackage (/usr/lib/electron/resources/default_app.asar/main.js:110:16)
    at Object.<anonymous> (/usr/lib/electron/resources/default_app.asar/main.js:222:9)
    at Module._compile (internal/modules/cjs/loader.js:1152:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1173:10)
The futex facility returned an unexpected error code.

If I try to call edit for an empty test.txt file I get

julia> edit("test.txt")
julia> The futex facility returned an unexpected error code.

Environemnt

  • Julia 1.5.3
  • Manjaro Linux
  • Code 1.53.2
  • Julia Extension 1.1.32

image

image

@pfitzseb
Copy link
Member

Can you check what ENV["EDITOR"] and ENV["JULIA_EDITOR"] are set to for you?

@pfitzseb pfitzseb added the bug label Mar 15, 2021
@pgagarinov
Copy link
Author

@pfitzseb

julia> ENV["EDITOR"]
ERROR: KeyError: key "EDITOR" not found
Stacktrace:
 [1] access_env at ./env.jl:43 [inlined]
 [2] getindex(::Base.EnvDict, ::String) at ./env.jl:79
 [3] top-level scope at REPL[3]:1

julia> ENV["JULIA_EDITOR"]
"\"/usr/lib/electron/electron\""

@pfitzseb
Copy link
Member

How did you install VSCode?

@pgagarinov
Copy link
Author

How did you install VSCode?

sudo pacman -S code

@pgagarinov
Copy link
Author

pgagarinov commented Mar 15, 2021

I set ENV["JULIA_EDITOR"] to "code" and have run a few experiments:

  1. when I run @edit min(1,2) in VSCode Julia REPL just nothing happens, no errors, just nothing.
  2. when I run code ./main.jl (main.jl exists) from terminal inside VSCode - thoing happens, no errors
  3. when I run @edit min(1,2) in Julia REPL that is oupened outside of VSCode - it works, VSCode is opens the source file.
  4. when I run code ./main.jl in an external terminal (not inside VSCode) - it also works.

If I sent ENV["JULIA_EDITOR"] = "vim" then steps 1 and 2 above work.

As far as I can tell there are two problems
a) JULIA_EDITOR is not initialized correctly for "code" on Manjaro Linux. Can't test on pure Arch Linux right now but I suspect that issue will reproduce there as well.

b) even when initalized correctly (to "code") Julia silently refuses to open the file with VSCode from a terminal or REPL that is launched from VSCode.

@pfitzseb
Copy link
Member

Well, we don't find the right path for the official distribution. Everything works fine if you build the AUR package yourself, for example. I'll play around with finding the correct path...

@pgagarinov
Copy link
Author

pgagarinov commented Mar 15, 2021

Well, we don't find the right path for the official distribution. Everything works fine if you build the AUR package yourself, for example. I'll play around with finding the correct path...

Sorry, I forgot to mention that all experiments 1-4 above I ran with julia-bin AUR
(installed via yay -S julia-bin). The reason I switched from julia official to julia-bin AUR today is to work around this problem:

JuliaLang/julia#40036

So switching to AUR at least informs @edit about the correct Julia Library source location (because @edit opens the source code when I sent JULIA_EDITOR to "nano" or "vim") but @edit still doesn't work when JULIA_EDITOR is set to "code" for some other reason...

@davidanthoff davidanthoff added this to the Backlog milestone Mar 16, 2021
@el-oso
Copy link

el-oso commented Mar 17, 2021

I have the same problem it seems. I am using Ubuntu:

Julia

julia> versioninfo()
Julia Version 1.6.0-rc2
Commit 4b6b9fe4d7 (2021-03-11 07:05 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: AMD Ryzen 9 3900XT 12-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, znver2)
Environment:
  JULIA_EDITOR = "/usr/share/code/code"
  JULIA_NUM_THREADS = 24

Ubuntu

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.2 LTS
Release:	20.04
Codename:	focal

VSCode

Version: 1.54.3
Commit: 2b9aebd5354a3629c3aba0a5f5df49f43d6689f8
Date: 2021-03-15T10:55:24.277Z
Electron: 11.3.0
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Linux x64 5.4.0-66-generic
julia> @edit isapprox(1e-10, 0, atol=1e-8)

julia> The futex facility returned an unexpected error code.
/dev/fd/3: No such file or directory
Server response: 

I can install whatever you want to test.

@pfitzseb pfitzseb mentioned this issue Mar 17, 2021
2 tasks
@el-oso
Copy link

el-oso commented Mar 18, 2021

@pfitzseb Does it take long until the fix is rolled out to VSCode? I have no idea about the process.

@pfitzseb
Copy link
Member

The fix should appear on the insiders channel within in the next day or so, I think.

@pgagarinov
Copy link
Author

@pfitzseb The fix doesn't solve the problem for me, when I call edit("somefile.jl") just nothing happens, silence.

image

I'm using the latest 1.1.38

@pfitzseb
Copy link
Member

What is ENV["JULIA_EDITOR"] set to for you?

@pfitzseb
Copy link
Member

You can now also set the julia.editor to something that works for you.

@pgagarinov
Copy link
Author

JULIA_EDITOR

julia> ENV["JULIA_EDITOR"]
"code"

Let me repeat myself, this is from the post above:

I set ENV["JULIA_EDITOR"] to "code" and have run a few experiments:

when I run @edit min(1,2) in VSCode Julia REPL just nothing happens, no errors, just nothing.
when I run code ./main.jl (main.jl exists) from terminal inside VSCode - thoing happens, no errors
when I run @edit min(1,2) in Julia REPL that is oupened outside of VSCode - it works, VSCode is opens the source file.
when I run code ./main.jl in an external terminal (not inside VSCode) - it also works.

If I sent ENV["JULIA_EDITOR"] = "vim" then steps 1 and 2 above work.

As far as I can tell there are two problems
a) JULIA_EDITOR is not initialized correctly for "code" on Manjaro Linux. Can't test on pure Arch Linux right now but I suspect that issue will reproduce there as well.

b) even when initalized correctly (to "code") Julia silently refuses to open the file with VSCode from a terminal or REPL that is launched from VSCode.

Thus, the problem is now not related to "JULIA_EDITOR" variable not being initialized correctly, it is related to the fact that even if it is initialized correctly edit doesn't open the tab with the target file if that edit is called FROM WITHIN vscode. If the same is done from the external REPL then everything works and edit('something') opens the tab inside vscode.

@pfitzseb
Copy link
Member

Must be a weird interaction with how Arch packages VSCode or something. The re-packaged code-bin versions work fine for me.

The PR above fixed auto-setting of JULIA_EDITOR to wrong values, nothing else. There's not too much we can do about whatever you're seeing bar overwriting edit like in Juno, but I'd rather not do that tbh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants