Unable to open files from integrated terminal in VSCode

Viewed 919

EDIT: setting $DISPLAY to the right value works. So I guess my real question is this: Why is VSCode not seeing $DISPLAY and some other env variables from the shell with which it was originally launched?

As title states, I can't open anything in code from the integrated terminal on my system running Pop!_OS. Launching code from a GNOME terminal works fine. I think there's something wrong with the DISPLAY env var (or rather code's ability to see it), but I'm relatively new to linux and don't really know how to go about fixing it.

From GNOME terminal (works fine):

$ touch foo
$ code --verbose foo
[main 2020-09-02T18:18:53.728Z] Sending env to running instance...
[main 2020-09-02T18:18:53.743Z] Sent env to running instance. Terminating...
[main 2020-09-02T18:18:53.743Z] Lifecycle#kill()
$ echo $DISPLAY
:1
$

And from VSCode integrated terminal:

$ touch foo
$ code --verbose -r foo
[4983:0902/140530.365110:ERROR:browser_main_loop.cc(1486)] Unable to open X display.
$ echo $DISPLAY

$
1 Answers

Check Integrated: Inherit Env is enabled in Settings from your VScode

Where,

File -> Preferences -> Settings -> Features -> Terminal -> Integrated: Inherit Env

in short way,

Ctrl + , (comma) -> type 'Inherit Env' at Search settings -> Terminal Integrated: Inherit Env

You can search it in the Settings window

To see the result, turn off the terminal and reopen it.

Related