microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.5k stars 29.38k forks source link

Warning about Node.js environment variables on launch #204005

Closed tillig closed 9 months ago

tillig commented 9 months ago

Type: Bug

If you have a NODE_EXTRA_CA_CERTS environment variable in place, then when launching VS Code from a command line, a warning message is displayed:

[0201/100616.044843:ERROR:node_main.cc(135)] Node.js environment variables are disabled because this process is invoked by other apps.

The extra certificates are required for our environment to support proxy/VPN connectivity. Ideally these values would be used in VS Code; but, at the very least, the warning shouldn't show up on the console during launch.

VS Code version: Code 1.86.0 (05047486b6df5eb8d44b2ecd70ea3bdf775fd937, 2024-01-31T10:29:11.933Z) OS version: Darwin arm64 23.3.0 Modes:

System Info |Item|Value| |---|---| |CPUs|Apple M1 Max (10 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|6, 4, 3| |Memory (System)|32.00GB (3.50GB free)| |Process Argv|--disable-extensions --crash-reporter-id 1021646e-a5d4-4a1c-bf5d-3f1296f9cf93| |Screen Reader|no| |VM|0%|
Extensions disabled
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscorecescf:30445987 vscod805cf:30301675 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:30899288 c4g48928:30535728 azure-dev_surveyone:30548225 0bi6i642:30951795 pythongtdpath:30769146 welcomedialog:30910333 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 pythontbext0:30879054 accentitlementst:30887150 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 dsvsc019b:30953937 3ef8e399:30949928 ```
galkin commented 9 months ago

Actually it can be any NODE specific env variable. I have this warning, because NODE_OPTIONS=--enable-source-maps

fritx commented 9 months ago

Actually it can be any NODE specific env variable. I have this warning, because NODE_OPTIONS=--enable-source-maps

Same here. I had exported such NODE_OPTIONS in my bashrc

# ~/.bashrc
# nodejs memory limit
# https://www.npmjs.com/package/increase-memory-limit
export NODE_OPTIONS=--max_old_space_size=4096
mtt87 commented 9 months ago

For a moment I thought this was related to my recent update of node from 20.10.0 to 20.11.0 but then I'm quite sure it's only related to VSCode. In case it helps

Version: 1.86.0 (Universal)
Commit: 05047486b6df5eb8d44b2ecd70ea3bdf775fd937
Date: 2024-01-31T10:29:15.765Z (2 days ago)
Electron: 27.2.3
ElectronBuildId: 26495564
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Darwin arm64 23.3.0
delfuego commented 9 months ago

Same here — vscode just updated this morning, and now typing code [path] at the command prompt generates this error every time.

vscode info:

Version: 1.86.0 (Universal)
Commit: 05047486b6df5eb8d44b2ecd70ea3bdf775fd937
Date: 2024-01-31T10:29:15.765Z (2 days ago)
Electron: 27.2.3
ElectronBuildId: 26495564
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Darwin arm64 23.3.0
j0nl1 commented 9 months ago

I updated vscode this morning and I'm experience the same issue, same behaviour every time I write code filename at the cli prompt generates this error every time.

Version: 1.86.0 (Universal)
Commit: 05047486b6df5eb8d44b2ecd70ea3bdf775fd937
Date: 2024-01-31T10:29:15.765Z
Electron: 27.2.3
ElectronBuildId: 26495564
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Darwin arm64 23.3.0
thomas-w-grant commented 9 months ago

❓ Is there a work around for this?

mtt87 commented 9 months ago

Personally I've not experienced any issues so it's just a warning that for now it can be ignored or is this causing problems for you? I'm not using VSCode terminal but I wonder if it can affect node running there?

kipmyk commented 9 months ago

Hey 👋, any workaround for this? I am getting the same issue. Thank you.

forivall commented 9 months ago

My workaround is that in the code wrapper shell script (located at /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code in macos, linux users can figure out where it is, ymmv on windows whether you're in WSL or not), just before

ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@", i add

unset NODE_VERSION_PREFIX
unset NODE_VERSIONS

(those env vars are provided by nvm, i think)

So, just add that for whatever NODE_* environment variables you have, such as

unset NODE_OPTIONS
unset NODE_EXTRA_CA_CERTS
GBrachetta commented 9 months ago

I also started having this since VSCode 1.86.0. I believe it's related to NVM. I have NVM installed with HomeBrew, and in my .zshrc file I have:

NVM_HOMEBREW="/opt/homebrew/opt/nvm/nvm.sh"
[ -s "$NVM_HOMEBREW" ] && \. "$NVM_HOMEBREW"
[ -x "$(command -v npm)" ] && export NODE_PATH=$NODE_PATH:`npm root -g`

I commented out the last line, so now it looks like:

NVM_HOMEBREW="/opt/homebrew/opt/nvm/nvm.sh"
[ -s "$NVM_HOMEBREW" ] && \. "$NVM_HOMEBREW"
# [ -x "$(command -v npm)" ] && export NODE_PATH=$NODE_PATH:`npm root -g`

For the time being this seems to work and I don't get anymore the warning when I run code [filename].

CaddyDz commented 9 months ago

I don't have node installed on my system at all and yet I get this error too, so am guessing it's most likely an internal vscode bug in the latest update

dtbuchholz commented 9 months ago

The issue stems from Electron (VSCode's build engine), where this error message is part of the source code: https://github.com/electron/electron/blob/2ebaebb603620f18ba231bda684f9af392c76923/shell/app/node_main.cc#L144

I resolved this issue on my end by removing any Node env vars from my ~/.zshrc file. In my case, all I had set was export NODE_NO_WARNINGS=1, and removing that line fixed it.

Fwiw, I recently updated to Mac OS Sonoma 14.3. Prior to that, I never ran into this issue. It's possible Apple tightened up security measures and introduced something that causes this warning to appear. That's the only thing I've changed on my machine since this issue started happening.

gwk commented 9 months ago

Inserting the following lines in the code.sh script above the invocation will unset all NODE_* vars:

for node_env_var in $(env | grep -E '^NODE_\w+' --only-matching); do
  unset $node_env_var
done
guw commented 9 months ago

This is MacOS only. But I suspect the check here may be too broad? https://github.com/electron/electron/blob/3ec04fd4492c889c070ed3d5c95b914a577c8864/shell/app/node_main.cc#L133C8-L133C55

When running code <whatever> from Terminal I do expect shell variables to be used/available inside Code. I also don't expect Code to run sandboxed in this case if it was properly installed into /Applications.

//cc @zcbenz

damingerdai commented 9 months ago

i also meet this issue

vscode version:

1.86.0
05047486b6df5eb8d44b2ecd70ea3bdf775fd937
arm64

macos:

14.2.1 (23C71)
vsnthdev commented 9 months ago

This also happens to me on macOS 14.3 (23D56) and VSCode version 👇

1.86.0
05047486b6df5eb8d44b2ecd70ea3bdf775fd937
x64
benderham commented 9 months ago

+1 also happening here on macOS 14.2.1 (23C71)

Version: 1.86.0 (Universal)
Commit: 05047486b6df5eb8d44b2ecd70ea3bdf775fd937
Date: 2024-01-31T10:29:15.765Z (4 days ago)
Electron: 27.2.3
ElectronBuildId: 26495564
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Darwin arm64 23.2.0
kud commented 9 months ago
❯ c
[0205/221330.306976:ERROR:node_main.cc(135)] Node.js environment variables are disabled because this process is invoked by other apps.

got the same here 😬

  System:
    OS: macOS 14.3
    CPU: (10) arm64 Apple M1 Pro
    Memory: 100.84 MB / 16.00 GB
    Shell: 5.9 - /opt/homebrew/bin/zsh
  Binaries:
    Node: 21.1.0 - ~/Library/Caches/fnm_multishells/21097_1707170535908/bin/node
    Yarn: 1.22.19 - ~/Library/Caches/fnm_multishells/21097_1707170535908/bin/yarn
    npm: 10.4.0 - ~/Library/Caches/fnm_multishells/21097_1707170535908/bin/npm
    pnpm: 7.22.0 - ~/Library/Caches/fnm_multishells/21097_1707170535908/bin/pnpm
  IDEs:
    VSCode: 1.86.0 - /usr/local/bin/code
    Vim: 9.1 - /opt/homebrew/bin/vim
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Bash: 5.2.26 - /opt/homebrew/bin/bash
beorn commented 9 months ago

If you install Node via Nix it sets NODE_PATH, so no way to avoid this error in that case.

wolfch-elsevier commented 9 months ago

My workaround is that in the code wrapper shell script (located at /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code in macos, linux users can figure out where it is, ymmv on windows whether you're in WSL or not), just before

ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@", i add

unset NODE_VERSION_PREFIX
unset NODE_VERSIONS

(those env vars are provided by nvm, i think)

So, just add that for whatever NODE_* environment variables you have, such as

unset NODE_OPTIONS
unset NODE_EXTRA_CA_CERTS

That's not a workaround if you need to set NODE_EXTRA_CA_CERTS to a self-signed certificate for a corporate VPN.

wolfch-elsevier commented 9 months ago

This is a total show-stopper for people working behind a corporate VPN and need to set NODE_EXTRA_CA_CERTS to the firewall/VPN isssuer certificate. I see that it's an Electron issue, not VSCode. But still, is there a way to downgrade VSCode to a version not using that broken version of Electon?

hoechenberger commented 9 months ago

Downgrading to 1.85 is what I did to work around this issue for now.

ryanblock commented 9 months ago

I've also been seeing this issue. If it may help triangulate: I do not use nvm (although it sounds like that's already been ruled out as the culprit), and similar to @beorn's comment, I do have NODE_PATH set – this is the sole Node-related env var in my shell.

blackswanny commented 9 months ago

same issue, I used to call code from my terminal as it picked up my env i carefully setup in bash. Now it ignores it all and doesn't work with any of my env flavors. Working and setting terminal inside VSCode I have no wish. Downgraded to 1.85

tillig commented 9 months ago

@deepak1556 Just to check - it appears the PR only handles NODE_OPTIONS and NODE_REPL_EXTERNAL_MODULE. What about others like NODE_EXTRA_CA_CERTS and NODE_VERSION_PREFIX that have been listed in this issue? Is there something sort of automatic about NODE_OPTIONS that just takes care of it?

blackswanny commented 9 months ago

@deepak1556 Just to check - it appears the PR only handles NODE_OPTIONS and NODE_REPL_EXTERNAL_MODULE. What about others like NODE_EXTRA_CA_CERTS and NODE_VERSION_PREFIX that have been listed in this issue? Is there something sort of automatic about NODE_OPTIONS that just takes care of it?

imho, we should inherit all environment variables from shell. There are so many needed and picked by VS Code tools, plugins, etc.

beorn commented 9 months ago

Agreed, since the PR only fixes NODE_OPTIONS it won't really fix the issue for all the other env vars. This issue is not closed.

zcbenz commented 9 months ago

The warnings about other envs were removed in Electron by https://github.com/electron/electron/pull/41079, wait for an update of Electron in VS Code and they should be gone.

tillig commented 9 months ago

AH! That was the missing piece of information. Thanks @zcbenz !

deepak1556 commented 9 months ago

The update which @zcbenz mentioned has landed via https://github.com/microsoft/vscode/pull/204580, please check out latest insiders and it should have all the necessary fixes.

mohsin commented 9 months ago

@deepak1556 Any idea on long does it take to be available publically so I can do a "Check for Updates" and see it?

vscodenpa commented 9 months ago

This bug has been fixed in the latest release of VS Code Insiders!

@tillig, you can help us out by commenting /verified if things are now working as expected.

If things still don't seem right, please ensure you're on version 7c15c66607256592202cc051fb3e117baf54af63 of Insiders (today's or later - you can use Help: About in the command palette to check), and leave a comment letting us know what isn't working as expected.

Happy Coding!

hajeklu commented 9 months ago

It seems to be fixed in version: 1.86.2

tillig commented 9 months ago

/verified

It does appear to be fixed in 1.86.2.

kud commented 9 months ago
Version: 1.86.2
Commit: 903b1e9d8990623e3d7da1df3d33db3e42d80eda
Date: 2024-02-13T19:42:12.210Z
Electron: 27.2.3
ElectronBuildId: 26908389
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Darwin arm64 23.3.0

fixed.

learnsomuch commented 7 months ago

I still have same problem with latest update

❯ git push [0418/115928.400333:ERROR:node_main.cc(149)] Node.js environment variables are disabled because this process is invoked by other apps.

Version: 1.88.1 (Universal) Commit: e170252f762678dec6ca2cc69aba1570769a5d39 Date: 2024-04-10T17:42:52.765Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Darwin arm64 23.4.0