Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode complains that resolving my environment takes too long

When I launch VSCode from the dock, it always complains that

Resolving your shell environment is taking very long. Please
review your shell configuration.

and then a bit later

Unable to resolve your shell environment in a reasonable time.
Please review your shell configuration.

According to this page, Resolving Shell Environment is Slow, the first message is displayed if .bashrc takes more than three seconds and the second is displayed if it takes longer than ten seconds.

I opened a terminal in VSCode and sourced my .bashrc file

dpatterson@dpconsulting$ time source ~/.bashrc
real    0m1.448s
user    0m0.524s
sys     0m0.671s

dpatterson@dpconsulting$ 

As you can see, it takes less than 1.5 seconds.

Environment:

  • MacOS Mojave 10.14.6
  • VSCode 1.53.0

Hopefully someone knows what is causing this.
Barring that, maybe someone can point me to the code that actually generates these errors.

TIA

like image 597
David Patterson Avatar asked Feb 11 '21 20:02

David Patterson


People also ask

Why is my Visual Studio Code so slow?

You might have extensions installed that slow Visual Studio down. For help on managing extensions to improve performance, see Change extension settings to improve performance. Similarly, you might have tool windows that slow Visual Studio down.

How can I make my VS Code faster?

Here's how to do it: Simply disable your extensions one at a time, and check to see if it made a difference. If your performance issues are obvious (E.g. files take 2 sec to open) than this should be quite easy. Disable → test → enable → disable the next one → test → etc.

How do you clean terminal in VS Code?

To clear Terminal in VS Code simply press Ctrl + Shift + P key together this will open a command palette and type command Terminal: Clear .

How do you stop a running file in VS Code?

VS Code maintains a debug session while the program is running, and pressing the Stop button terminates the program.


2 Answers

encountered the same situation and find the issue: https://github.com/microsoft/vscode/issues/113869#issuecomment-780072904

I extract nvm load code to the condition function ref in the issue, solved this problem:

function load-nvm {
  export NVM_DIR="$HOME/.nvm"
  [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
  [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
  [[ -s `brew --prefix`/etc/autojump.sh ]] && . `brew --prefix`/etc/autojump.sh
}

# nvm
if [[ "x${TERM_PROGRAM}" = "xvscode" ]]; then 
  echo 'in vscode, nvm not work; use `load-nvm`';
else 
  load-nvm
fi

like image 52
Hemisu Avatar answered Oct 04 '22 14:10

Hemisu


Open VS Code from a terminal:

code .
like image 32
taraslis453 Avatar answered Oct 04 '22 16:10

taraslis453