# VSCode gives Node.js "open EISDIR" error when opening file from REPL

**URL:** <https://discourse.julialang.org/t/vscode-gives-node-js-open-eisdir-error-when-opening-file-from-repl/108540>\
**Category:** Tooling\
**Tags:** repl, vscode\
**Created:** [January 8, 2024, 10:10pm UTC](https://discourse.julialang.org/t/vscode-gives-node-js-open-eisdir-error-when-opening-file-from-repl/108540 "2024-01-08T22:10:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikmoore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikmoore/32/31109_2.png) [@mikmoore](https://discourse.julialang.org/u/mikmoore)\
**Post date:** [January 8, 2024, 10:10pm UTC](https://discourse.julialang.org/t/vscode-gives-node-js-open-eisdir-error-when-opening-file-from-repl/108540/1 "2024-01-08T22:10:51Z")

</div>

Several months ago, I started getting an error ~~when I use control+q to open a location in a stack trace or method list after entering an index into that list on the REPL~~ any time I attempt to open a file from the REPL while `ENV["EDITOR"] = "code"`. The error I get is the following (printed at the REPL):

```julia
node:net:413
      throw errnoException(err, 'open');
      ^

Error: open EISDIR
    at new Socket (node:net:413:13)
    at createWritableStdioStream (node:internal/bootstrap/switches/is_main_thread:78:18)
    at process.getStderr [as stderr] (node:internal/bootstrap/switches/is_main_thread:170:12)
    at console.get (node:internal/console/constructor:220:44)
    at console.value (node:internal/console/constructor:347:50)
    at console.warn (node:internal/console/constructor:382:61)
    at Object.h [as onError] (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:1:7727)
    at _.onError (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:1:12590)
    at h._onLoadError (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:3:7877)
    at l (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:3:9082)
    at Object.errorback (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:3:9457)
    at d.triggerErrorback (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:1:13508)
    at C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:1:13259
    at i.load (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:2:1654)
    at d.load (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:1:13214)
    at l (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:3:9338)
    at Object.errorback (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:3:9457)
    at d.triggerErrorback (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:1:13508)
    at C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:1:13259
    at i.load (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:2:1654)
    at d.load (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:1:13214)
    at l (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:3:9338)
    at h._loadModule (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:3:9466)
    at h._resolve (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:4:452)
    at h.defineModule (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:3:5561)
    at _ (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:4:1741)
    at m (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:2:2448)
    at Object.<anonymous> (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\code\node\cli.js:31:28)
    at Object.<anonymous> (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\code\node\cli.js:31:27732)
    at i._createAndEvalScript (C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:2:2492)
    at C:\Users\mikm\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js:2:2133
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
  errno: -4068,
  code: 'EISDIR',
  syscall: 'open'
}

Node.js v18.15.0

```

As best I can tell from reading online, EISDIR is thrown when Node.js intends to open a file but receives a directory.

The issue is resolved and the file opens successfully with my environment’s `EDITOR=vim` or another editor, but I’m hoping to get this working again with my preferred editor `code`. I can call `code --goto ~/julia-1.10.0/share/julia/base/math.jl:50` and VSCode successfully opens the specified file to the requested line number, so it (naively) seems that something is wrong in the Julia interface to it. My VS Code installation affirms it is up to date. Julia is installed and run from a WSL Ubuntu install on a Windows 10 machine.

This functionality had worked on this machine for years but no longer does. I wish I remembered whether this started failing after a VS Code or Julia update, but I don’t. Does anyone have a suggestion with how to resolve this?

---

<div class="post-metadata">

**Author:** ![mikmoore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikmoore/32/31109_2.png) [@mikmoore](https://discourse.julialang.org/u/mikmoore)\
**Post date:** [January 29, 2024, 9:17pm UTC](https://discourse.julialang.org/t/vscode-gives-node-js-open-eisdir-error-when-opening-file-from-repl/108540/2 "2024-01-29T21:17:43Z")

</div>

I’ll add that the same issue arises with a use of `@edit`, such as `@edit exp(1.0)`. The issue occurs when running Julia from a standalone terminal. `@edit` works properly when running from a REPL within a terminal hosted within VSCode (presumably `^q` would work except that it snags on a VSCode shortcut).

---

<div class="post-metadata">

**Author:** ![mikmoore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikmoore/32/31109_2.png) [@mikmoore](https://discourse.julialang.org/u/mikmoore)\
**Post date:** [February 13, 2024, 2:41pm UTC](https://discourse.julialang.org/t/vscode-gives-node-js-open-eisdir-error-when-opening-file-from-repl/108540/3 "2024-02-13T14:41:39Z")

</div>

In what should have been no surprise, this error occurs when attempting to edit a file directly from the REPL, such as `edit("path/to/file.jl")`. Special modes of opening specific methods are irrelevant.

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [February 13, 2024, 5:57pm UTC](https://discourse.julialang.org/t/vscode-gives-node-js-open-eisdir-error-when-opening-file-from-repl/108540/4 "2024-02-13T17:57:10Z")

</div>

> [@mikmoore](#):
>
> `EISDIR`

You might want to look closely at your vscode settings.

This SO post suggests it has to do with confusion brtween opening a directory or file:

> <https://stackoverflow.com/questions/20417118/using-node-js-i-get-error-eisdir-read>

Perhaps there is some setting the Julia environment which is messed up?

---

<div class="post-metadata">

**Author:** ![mikmoore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikmoore/32/31109_2.png) [@mikmoore](https://discourse.julialang.org/u/mikmoore)\
**Post date:** [February 13, 2024, 7:28pm UTC](https://discourse.julialang.org/t/vscode-gives-node-js-open-eisdir-error-when-opening-file-from-repl/108540/5 "2024-02-13T19:28:59Z")

</div>

Thanks. This didn’t directly help me, but it led me down the right rabbit hole. There’s some issue with redirecting stdout via `pipeline` when run from a standalone terminal (but not a VS Code terminal).

I opened [`edit` with VS Code from a standalone terminal · Issue #53321 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/53321) with more info.

---

<div class="post-metadata">

**Author:** ![mikmoore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikmoore/32/31109_2.png) [@mikmoore](https://discourse.julialang.org/u/mikmoore)\
**Post date:** [February 14, 2024, 4:34pm UTC](https://discourse.julialang.org/t/vscode-gives-node-js-open-eisdir-error-when-opening-file-from-repl/108540/6 "2024-02-14T16:34:23Z")

</div>

I’ve managed to sidestep this issue in the meantime by adding the following to my `startup.jl`:

```julia
# workaround for editor interaction issue https://github.com/JuliaLang/julia/issues/53321
atreplinit() do _
    InteractiveUtils.define_editor(["code", "code-insiders"]; wait=true) do cmd, path, line, column
        `$cmd -g $path:$line:$column`
    end
end

```

This doesn’t seem like the proper fix, but it’s working for me for now while the above-linked issue remains open.
