vscode: `Unable to resolve your shell environment` notification after VS Code restored during MacOS restart

Issue Type: Bug

Repro

  1. Restart MacOS so that a VS Code window is restored
  2. See a notification: Unable to resolve your shell environment in a reasonable time. Please review your shell configuration.

VS Code version: Code - Insiders 1.53.0-insider (a48ef56fbf7767f55a193d7d5687addd1fc9239c, 2021-01-05T05:22:22.983Z) OS version: Darwin x64 20.2.0

System Info
Item Value
CPUs Intel® Core™ i7-7700K CPU @ 4.20GHz (8 x 4200)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 141, 41, 16
Memory (System) 40.00GB (26.72GB free)
Process Argv –crash-reporter-id cefe23df-690f-4b1b-9ce9-e004d3be2745
Screen Reader no
VM 0%
Extensions (27)
Extension Author (truncated) Version
spellright ban 3.0.52
color-info bie 0.5.1
comment-tagged-templates bie 0.3.1
docs-view bie 0.0.8
emojisense bie 0.8.0
gif-player bie 0.0.2
speech bie 0.0.3
vscode-eslint dba 2.1.14
gitlens eam 11.1.3
vscode-pull-request-github Git 0.22.0
vscode-azurefunctions ms- 1.1.0
vscode-docker ms- 1.9.0
python ms- 2020.12.424452561
vscode-pylance ms- 2020.12.2
jupyter ms- 2020.12.414227025
remote-containers ms- 0.154.2
azure-account ms- 0.9.4
cpptools ms- 1.1.3
wordcount ms- 0.1.0
debugger-for-chrome msj 4.12.11
language-liquid nei 0.1.1
polacode pnp 0.3.4
shader sle 1.1.4
code-spell-checker str 1.10.2
sort-lines Tyr 1.9.0
sourcekit-lsp unp 0.0.1
material-theme zhu 3.9.12

(3 theme extensions excluded)

A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368:30146709
vsreu685:30147344
openlogontheside:30221882
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30208929
wsl2prompt:30219162
vstry244:30230484
pythonvsdeb440:30224570
unusedprompt:30219164
folderexplorer:30219166
openfilemenucf:30219169
pythonvsded773:30223139
pythonvspyt600:30241727
core-portspanel:30233467

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 32
  • Comments: 28 (4 by maintainers)

Most upvoted comments

An option to disable this would be great.

I’m having the same problem on my Linux KDE desktop.

When started from the Starter menu it will display this error after 10 seconds, when started from the command line it will block indefinitely and not start at all.

There are no “potentially long running” commands in my .bashrc, it runs just fine when starting a bash session and never gave me any problems, in fact I haven’t touched my .bashrc for a few years at all because it is perfect and code has been running fine all the time, this FAQ is not helpful at all.

How can I debug this issue? How can I disable this .bashrc scanning entirely, it doesn’t need to parse my bashrc, its just a frickin text editor!? If you need the environment variables then use the goddamn API functions to read them like any other program does! VScode used to work extremely well, I regarded it as the best editor on this planet and recommended it to everyone. And suddenly it starts to go downwards very fast, you are destroying a perfect product by adding useless stuff and fixing things that aren’t broken out of pure boredom. Is this a Microsoft specific behaviour?

What to do with this issue? seriously, man, I am freaking out due to this behavior. I am using Ubuntu 16.04 and I am launching it through desktop Icon. Yesterday I tried the following method to fix my error.

preferences ->settings -> search for git.terminalAuthenticaiton -> uncheck that checkbox-> restart VScode

It worked for that moment. But it’s not working today. The same problem of shell environment.

If you have any solution then please tell me or give any useful link/reference

I am working on some main projects and I need to resolve this problem as soon as possible.

Thank you in advance

As far as I know, the solution is to open vscode through a terminal window.

code

I wouldn’t freak out over this behavior…

Same issue : Happens every time that vscode is open after a reboot of the system. The notification appear AND anything in the terminal will fail (“npm not found” if I try to start a task from the package.json). I have to quit then restart vscode and then for some reason everything is ok. What’s the difference between the first launch and the second ? (I don’t use the command line, only the dock icon)

On macos, I use nvm (because node on mac is a nightmare), everything’s up to date.

Does VS Code define any environment variables I could test for in the relevant files to have it ignore the slow parts that are making it take too long to resolve? e.g.:

if [ "x${VSCODE}" = "xYES" ]; then
    # (skip doing anything)
else
    # (run slow code) 
fi

or something

When VS Code is launched from a terminal (for example, via code .), it has access to environment settings defined in your .bashrc or .zshrc files. This means features like tasks or debug targets also have access to those settings.

However, when launching from your platform’s user interface (for example, the VS Code icon in the macOS dock), you normally are not running in the context of a shell and you don’t have access to those environment settings. This means that depending on how you launch VS Code, you may not have the same environment. See here https://code.visualstudio.com/docs/supporting/faq#_resolving-shell-environment-is-slow-error-warning

@lazarillo The real fix for this is #108804

We already wait for more than 3 seconds. The notification simply shows up as a warning.

@joaomoreno , I have looked at the “Learn More”, but it just tells me about things to look for to speed it up.

I actually do not care that it takes longer. I am just not sure if this causes any further problems. I would like to simply give a longer time that it is allowed to wait to resolve. I can wait 30 seconds or even a minute: It’s not as if I am doing something that needs my environment immediately upon opening VS code.

Can I alter the setting so that it does not complain about this? Is there any real problem with this “error”? I don’t care that my .zshrc file is slow… I have a lot of things to launch and I am OK with that.

Have you followed up on the Learn More link, which appears in that notification? It explains the problem and explores solutions.

If you do not want to debug your shell scripts, there are two workarounds:

  1. Ignore the notification and know that features will break (eg can’t debug NodeJS apps due to using nvm)
  2. Launch Code from a shell

dumb question… is your default shell bash?

Yes.

i think you need to use [[ ]] to test string equality in bash:

bash-3.2$ if [[ "x${TERM_PROGRAM}" = "xvscode" ]]; then echo true; else echo false; fi
false
bash-3.2$ echo $TERM_PROGRAM
iTerm.app
bash-3.2$ if [[ "x${TERM_PROGRAM}" = "xiTerm.app" ]]; then echo true; else echo false; fi
true

OK I tried changing it to that; it doesn’t help.