vscode icon indicating copy to clipboard operation
vscode copied to clipboard

launching vscode and shows "Unable to resolve your shell environment“

Open szbkdcsm opened this issue 5 months ago • 4 comments

Hi ! I have a problem that I can't solve and would like to seek help or report the issue.

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.101.0
  • OS Version: 10.0.26100

Version: 1.101.0 (system setup) Commit: dfaf44141ea9deb3b4096f7cd6d24e00c147a4b1 Date: 2025-06-11T15:00:50.123Z Electron: 35.5.1 ElectronBuildId: 11727614 Chromium: 134.0.6998.205 Node.js: 22.15.1 V8: 13.4.114.21-electron.0 OS: Windows_NT x64 10.0.26100

Steps to Reproduce:

  1. open the latest vscode in win11 24H2 26100.4351
  2. popup notification in the bottom right corner : "Unable to resolve your shell environment: Unexpected exit code from spawned shell (code 3762504530, signal null)"

Image

I tried reinstalling, but this warning still pops up for both the user version and the admin version.

I set application.shellEnvironmentResolutionTimeout 120 , but it do not work.

However, I found that entering "code --verbose" in PowerShell opens VSCode without any warnings.

The uploaded .zip file is my log file, hoping it can be helpful.

szbkdcsm avatar Jun 15 '25 07:06 szbkdcsm

I get a slightly different error message. Here is the output of main with log level set to trace.

Image

I don't get the error with vscode --verbose either.

  • Windows 11 24H2 26100.4351 x64
  • VSCode v1.101.0 (user setup) x64

o-l-a-v avatar Jun 15 '25 11:06 o-l-a-v

I get a slightly different error message. Here is the output of main with log level set to trace.我收到的错误消息略有不同。以下是 log level 设置为 trace 的 main 的输出。

Image

I don't get the error with vscode --verbose either.我也没有收到 vscode --verbose 的错误。

  • Windows 11 24H2 26100.4351 x64窗户 11 24H2 26100.4351 x64
  • VSCode v1.101.0 (user setup) x64VSCode v1.101.0(用户设置)x64

Hi, thank you for your reply!

I saw a problem with the same error message as yours : #251326 .

In fact, I didn't have this error message before I updated VSCode and Windows 11 yesterday.

I have now found that if I install the April 2025 (version 1.100) of vscode, this error completely disappears.

This seems to be caused by the latest version.

I have rolled back to the previous version and hope the issues will be fixed in the next version.

Thank you again for your help!

szbkdcsm avatar Jun 15 '25 11:06 szbkdcsm

I got this also, on Windows... when I clicked "Learn More" I got a help page that says "This section applies to macOS and Linux environments only." so definitely something wonky going on here :(

Not sure if it's related or not, but sine the same update, I'm also seeing CoPilot icons & prompts all over the place even though I don't have the CoPilot extensions installed & have as many of the chat enabled settings as I can find set to false

af4jm avatar Jun 15 '25 15:06 af4jm

I use Git Bass as default shell on Windows. It also happens to me many times but not always and I have no clue how to fix it😭

iwangbowen avatar Jun 16 '25 01:06 iwangbowen

After the upgrade to the:

Image

I have errors like below:

Image

I don't remember which version I upgraded from, but previously, there weren't such errors.

vonbartas avatar Jun 17 '25 05:06 vonbartas

After installing "command not found" from PowerToys I have only that:

Image

vonbartas avatar Jun 17 '25 05:06 vonbartas

For me, only the latest version(1.101) will have the initial issue.

I saw the following changes in the update log of this version and guessed the possible reasons.

Image

I also installed PowerToys, but no problems occurred.

szbkdcsm avatar Jun 17 '25 08:06 szbkdcsm

Errors are only in VSCode, not in the terminal itself.

vonbartas avatar Jun 17 '25 08:06 vonbartas

This bug stated affecting me immediately after the update 1.101.0

Image

However I have found I can launch VSCode from the existing C:\Program Files\Microsoft VS Code\bin\code.cmd possibly relating to inheriting the environment from the CLI - as per documentation

The contents of file look rather innocuous.

@echo off
setlocal
set VSCODE_DEV=
set ELECTRON_RUN_AS_NODE=1
"%~dp0..\Code.exe" "%~dp0..\resources\app\out\cli.js" %*
IF %ERRORLEVEL% NEQ 0 EXIT /b %ERRORLEVEL%
endlocal

I have no idea if this is a viable workaround, I only know the error does not occur when I launch from this but the whatever symptoms may still persist.

andyg2 avatar Jun 17 '25 12:06 andyg2

Yes, I also found that if I open VSCode from cmd/powershell, there will be no error prompts.

Actually, even if there are error prompts, the terminal in VSCode can still be used normally.

My guess is the same as yours:

When opening VSCode, it fails to load the correct shell environment, whereas opening it from cmd automatically inherits the parent process's environment.

szbkdcsm avatar Jun 17 '25 12:06 szbkdcsm

In my scenario, VSCode fails to resolve certain settings from my $PROFILE during startup. To handle this, I conditionally disable these settings when running in VSCode:

# Microsoft.PowerShell_profile.ps1

if (-not $env:VSCODE_PID) {
  # These settings are skipped in VSCode as they aren't resolved properly during startup
  $Host.UI.RawUI.WindowTitle = "pwsh.exe"
  Import-Module -Name Microsoft.WinGet.CommandNotFound
}

zeekcheung avatar Jun 20 '25 03:06 zeekcheung

This might have been caused by https://github.com/microsoft/vscode/issues/249130, passing to @connor4312

Tyriar avatar Jun 20 '25 19:06 Tyriar

Some of your issues may already be fixed on VS Code Insiders. If they are not, please:

  1. Run "Configure Runtime Arguments" and set "log-level": "trace"
  2. Completely close VS code, including all Windows
  3. Open VS Code from your desktop or app browser (not a terminal)
  4. Go to Output > Main and share the logs with us

connor4312 avatar Jun 20 '25 19:06 connor4312

Interesting thing, after uninstalling the EntraID extension, it is better. I saw this error message only once. I'll observe the application behavior, and if the message pops up, I enable logging.

vonbartas avatar Jun 24 '25 04:06 vonbartas

Funny fact: not always opening VSCode is starting "Resolving Shell Environment" or is so quick that I cannot notice. The first opening caused an error, closing VSCode, and opening it once again, but it did not show any errors. When you are doing it quickly. When you wait a few minutes, "Resolving Shell Environment" is showing longer, and an error is appearing.

vonbartas avatar Jun 25 '25 05:06 vonbartas

@connor4312 How would you like me to send the logs?

vonbartas avatar Jun 25 '25 08:06 vonbartas

You can post them here or email to [email protected]

connor4312 avatar Jun 25 '25 14:06 connor4312

You can post them here or email to [email protected]

sent

vonbartas avatar Jun 29 '25 07:06 vonbartas

Fixed in Insiders

connor4312 avatar Jun 29 '25 15:06 connor4312

Fixed in Insiders

Looks like it's fixed. Thank you @connor4312, great job 🥇

vonbartas avatar Jul 01 '25 05:07 vonbartas