• Love this snippet!

    One thing I would like to fix is that the integrated terminal does not work when opening VC this way, at least not on my setup with Debian Buster. No problem when opening code with "code ." from terminal.

  • @whitestonex: Perhaps I can try and help in figuring this one out. Would you be willing to provide more details? I tested and it works perfectly well for me (on nemo/cinnamon 4.4.0).

    Why doesn't it work - what is the exact symptom?

    Edited by Marc Ranolfi
  • Hi, thanks for replying.

    My setup is Debian Buster with cinnamon/stable,now 3.8.8-1 amd64

    To replicate (on my system):

    • Create a new folder
    • Create an app.js file (containing e.g. console.log('test');) inside the new folder.
    • Open Nemo, navigate to newly created folder.
    • Right click the empty area below the app.js file in the folder and choose Open with Code

    Now the terminal will not open, i.e. the terminal prompt does not show up.

    If I close Code and reopen Code from the Cinnamon menu, Code opens the same folder, but now terminal works fine. If I then close Code again and open Code by right clicking and choosing Open with Code as described above terminal does not work. EDIT: If I already have a Code window open before I do the right click procedure, the terminal works all fine!

    The same happens for existing Code projects I´ve got.

    I tried to disable all extensions in Code and restarted, but that did not help.

    Edited by Bjørnar Hvidsten
  • Hi, I found out why this happens. It´s the "terminal.integrated.inheritEnv": false" in settings.json that triggers this behaviour.

    https://github.com/microsoft/vscode/issues/76542

    Since I don´t need this setting for now I´ll just comment it out until it gets resolved.

    Edited by Bjørnar Hvidsten
  • Hunter Raffety @hunterraffety ·

    Very helpful, thank you

  • @whitestonex: Interesting. It seems I can't reproduce your error even with that setting marked as false and following your precise instructions. Of course whenever I launch Code within a new folder it doesn't already know, the terminal won't show up, but I just need to go to 'View -> Terminal' to enable it and it'll stay that way, no matter how I launch it in the future.

    I wonder if this is due to my newer version of Nemo (I'm now on v4.4.1).

    Anyway, if you could provide me the full command line that shows up on System Monitor (I use htop to copy it) it might help me figure out something. In my case, this is what I get:

    • /usr/lib/electron6/electron --no-sandbox /usr/lib/code/code.js . when launching via gnome-terminal (with code .) from within the project directory

    • /usr/lib/electron6/electron --no-sandbox /usr/lib/code/code.js /media/Docs/std-bad-alloc-test when launching via the menu entry on Nemo

    In both cases I run env in the integrated terminal and the output is the same:

    COLORTERM=truecolor
    TERM_PROGRAM_VERSION=1.40.2
    PWD=/media/Docs/std-bad-alloc-test
    LANG=en_US.UTF-8
    TERM=xterm-256color
    SHLVL=1
    TERM_PROGRAM=vscode
    _=/usr/bin/env

    This is with "terminal.integrated.inheritEnv": false". If I have it set to true (the default), however, there are the following differences in the output of env:

    • Launching via gnome-terminal: VTE_VERSION=5803; GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/86e0a12f_7666_4b0e_b359_0dc67547ddaf; GNOME_TERMINAL_SERVICE=:1.62; SHLVL=2; DESKTOP_AUTOSTART_ID=10b62081aa7b696e3a157621594574654200000008680037 and OLDPWD=/home/ranolfi are all set

    • launching via menu entry on Nemo: SHLVL=1; GIO_LAUNCHED_DESKTOP_FILE_PID=83966 and GIO_LAUNCHED_DESKTOP_FILE=/usr/share/applications/nemo.desktop are set.

    All other environment variables are identical, including PWD (which points to the right working dir).

    Also, it's not clear from your previous messages if you already tried it, but if not, please try bringing up the terminal via the 'View' menu.

    Regards

    Edited by Marc Ranolfi
  • @ranolfi Yes, it might be the Nemo version. I did try opening terminal via the View menu, same effect there.

    Here is the commandline output (don´t get electron there as you do, checked with ps, htop and system monitor)

    Starting Code from rightclick menu

    /usr/share/code/code --no-sandbox /home/whitestone/Downloads/js-complete-guide-2020/oop-08-shopping-cart-extending

    Starting Code from terminal 'code .'

    /usr/share/code/code --no-sandbox .

    Diff between envs:

    env from Code integrated terminal (without terminal.integrated.inheritEnv": false)

    SHLVL=2
    GIO_LAUNCHED_DESKTOP_FILE_PID=6132
    GIO_LAUNCHED_DESKTOP_FILE=/usr/share/gnome/applications/nemo.desktop
    TERM_PROGRAM_VERSION=1.40.2
    APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL=true
    NO_AT_BRIDGE=1
    CHROME_DESKTOP=code-url-handler.desktop

    env from terminal (not Code integrated terminal)

    SHLVL=1
    GNOME_TERMINAL_SERVICE=:1.144
    GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/06646a72_119f_4caf_87e9_71d524d444b4
    VTE_VERSION=5402
    Edited by Bjørnar Hvidsten
  • @whitestonex: Interesting. It seems the official binary version for Debian is quite different from the open source build distributed by Arch Linux. The former contains a binary launcher under /usr/share/code/code; the latter has a shell script under /usr/bin/code-oss (symlinked as /usr/bin/code) which launches VS Code as:

    ELECTRON_RUN_AS_NODE=1 exec electron6 /usr/lib/code/out/cli.js /usr/lib/code/code.js "$@"

    This appears to be an Arch's custom package doing. The 'code' binary launcher is not distributed at all.

    There are two things that you can try... in the nemo action launcher, change line #5 to either:

    1. Exec=/usr/share/code/bin/code %P, or

    2. Exec=gtk-launch code %P

    Then test as you used to (with terminal.integrated.inheritEnv set to "true").

    A more appropriate diagnosing would require me to install the proper official Debian release, which I can't do easily. I tried installing the generic tar.gz release (via this AUR package), but it worked out-of-the-box.
    I even went so far as to modify the symlink put under /usr/bin to point to the code binary launcher (in this case, under /opt/visual-studio-code and equivalent to your /usr/share/code/code (note: not /usr/share/code/bin/code), and also changing the nemo action launcher to load that binary directly, and still, the integrated terminal worked without issues.

    Edited by Marc Ranolfi
  • @ranolfi

    I got the same result with Exec=/usr/share/code/bin/code %P and Exec=gtk-launch code %P.

    I even tried to launch code via a terminal window like this:

    [Nemo Action]
    
    Name=Open with Code via terminal
    Comment=Opens VSCode in the current directory
    Exec=xterm -e "bash /home/whitestone/.local/share/nemo/scripts/open-visual-code-current-directory.sh %P"
    Icon-Name=code
    Dependencies=code;
    Selection=none
    Extensions=any;
    Quote=double

    open-visual-code-current-directory.sh

    #!/bin/bash
    
    cd $1
    code .

    Still the same result even if code . typed manually from terminal works!? A mystery to me, but of course there is a logical answer somewhere, a fresh linux install or updating Nemo might do the trick. But for now I`ll let it be and enjoy coding instead :) Really greatful for great support though!!! I´ll probably dig into the mystery again later...

    Edited by Bjørnar Hvidsten
  • Thanks for testing @whitestonex! Really strange indeed.

    I'm also letting it be, for the time being. Who knows, maybe at some point we'll figure this out.

    Regards o/

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment