Skip to content

macOS PowerShell: Unable to resolve your shell environment #240234

@sakuk005

Description

@sakuk005

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

  • VS Code Version: 1.97.0 (33fc5a9), Electron 32.2.7 (10660205)
  • OS Version: Darwin arm64 23.5.0 (macOS 14.5)

Steps to Reproduce:

  • Install pwsh via homebrew.
  • Run chsh -s /opt/homebrew/opt/powershell/bin/pwsh.
  • Install VS Code and launch from the dock (NOT from command line).
  • Notification in the bottom right: "Unable to resolve your shell environment: Unexpected exit code from spawned shell (code 1, signal null)"

Logs:

2025-02-10 08:29:36.415 [trace] [File Watcher (node.js)] Request to start watching: /Users/redacted/Library/Application Support/Code/User (excludes: <none>, includes: <all>, filter: <none>, correlationId: <none>),/Users/redacted/Library/Application Support/Code/User/settings.json (excludes: <none>, includes: <all>, filter: <none>, correlationId: <none>)
2025-02-10 08:29:36.415 [debug] Starting VS Code
2025-02-10 08:29:36.415 [debug] from: /Applications/Visual Studio Code.app/Contents/Resources/app
2025-02-10 08:29:36.415 [debug] args: {"_":[],"diff":false,"merge":false,"add":false,"remove":false,"goto":false,"new-window":false,"reuse-window":false,"wait":false,"help":false,"list-extensions":false,"show-versions":false,"pre-release":false,"update-extensions":false,"version":false,"verbose":false,"log":["trace"],"status":false,"prof-startup":false,"no-cached-data":false,"prof-v8-extensions":false,"disable-extensions":false,"disable-lcd-text":false,"disable-gpu":false,"disable-chromium-sandbox":false,"sandbox":false,"telemetry":false,"debugRenderer":false,"enable-smoke-test-driver":false,"logExtensionHostCommunication":false,"skip-release-notes":false,"skip-welcome":false,"disable-telemetry":false,"disable-updates":false,"use-inmemory-secretstorage":false,"disable-workspace-trust":false,"disable-crash-reporter":false,"crash-reporter-directory":"/Users/redacted/Downloads/vscode-dump/","skip-add-to-recently-opened":false,"open-url":false,"file-write":false,"file-chmod":false,"force":false,"do-not-sync":false,"do-not-include-pack-dependencies":false,"trace":false,"preserve-env":false,"force-user-env":false,"force-disable-user-env":false,"open-devtools":false,"disable-gpu-sandbox":false,"__enable-file-policy":false,"enable-coi":false,"no-proxy-server":false,"no-sandbox":false,"nolazy":false,"force-renderer-accessibility":false,"ignore-certificate-errors":false,"allow-insecure-localhost":false,"disable-dev-shm-usage":false,"profile-temp":false,"logsPath":"/Users/redacted/Library/Application Support/Code/logs/20250210T082936"}
2025-02-10 08:29:36.415 [trace] Resolving machine identifier...
2025-02-10 08:29:36.415 [trace] Resolved machine identifier: ba0700385ebbc38a28812767a179d2d3b5678411ce9d6abe083150274da4c51b
2025-02-10 08:29:36.415 [trace] Main->SharedProcess#connect
2025-02-10 08:29:36.415 [trace] StorageMainService: creating application storage
2025-02-10 08:29:36.415 [trace] ElectronURLListener: waiting for window to be ready to handle URLs...
2025-02-10 08:29:36.415 [trace] lifecycle (main): phase changed (value: 2)
2025-02-10 08:29:36.415 [trace] windowsManager#open
2025-02-10 08:29:36.415 [trace] windowsManager#open pathsToOpen [{"backupPath":"/Users/redacted/Library/Application Support/Code/Backups/1739191149929"}]
2025-02-10 08:29:36.415 [trace] windowsManager#doOpenEmpty {"restore":true,"forceNewWindow":true}
2025-02-10 08:29:36.415 [trace] IPC Object URL: Registered new channel vscode:2422052d-880f-4c7e-8110-9a02468a8fb4.
2025-02-10 08:29:36.415 [trace] window#validateWindowState: validating window state on 2 display(s) {"mode":1,"x":1728,"y":-1020,"width":3840,"height":1575}
2025-02-10 08:29:36.415 [trace] window#validateWindowState: multi-monitor working area {"x":1728,"y":-1020,"width":3840,"height":1575}
2025-02-10 08:29:36.415 [trace] window#ctor: using window state {"mode":1,"x":1728,"y":-1020,"width":3840,"height":1575}
2025-02-10 08:29:36.415 [trace] window#load: attempt to load window (id: 1)
2025-02-10 08:29:36.415 [trace] windowsManager#open used window count 1 (workspacesToOpen: 0, foldersToOpen: 0, emptyToRestore: 1, maybeOpenEmptyWindow: false)
2025-02-10 08:29:36.415 [trace] lifecycle (main): phase changed (value: 3)
2025-02-10 08:29:36.415 [trace] resolveShellEnv(): running (macOS/Linux)
2025-02-10 08:29:36.415 [trace] getUnixShellEnvironment#runAsNode undefined
2025-02-10 08:29:36.415 [trace] getUnixShellEnvironment#noAttach undefined
2025-02-10 08:29:36.415 [trace] getUnixShellEnvironment#env {"PWD":"/Users/redacted","SNC_LIB_64":"/Applications/Secure Login Client.app/Contents/MacOS/lib/libsapcrypto.dylib","MallocNanoZone":"0","USER":"redacted","SSF_LIBRARY_PATH":"/Applications/Secure Login Client.app/Contents/MacOS/lib/libsapcrypto.dylib","__CFBundleIdentifier":"com.microsoft.VSCode","COMMAND_MODE":"unix2003","SNC_LIB":"/Applications/Secure Login Client.app/Contents/MacOS/lib/libsapcrypto.dylib","PATH":"/usr/bin:/bin:/usr/sbin:/sbin","LOGNAME":"redacted","SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.Pto6cyTVD4/Listeners","SHLVL":"1","SHELL":"/usr/local/bin/pwsh","_":"/usr/bin/open","HOME":"/Users/redacted","SSF_LIBRARY_PATH_64":"/Applications/Secure Login Client.app/Contents/MacOS/lib/libsapcrypto.dylib","TMPDIR":"/var/folders/td/rl042hjn10x7ckfjtflv2kp40000gp/T/","__CF_USER_TEXT_ENCODING":"0x1F6:0x0:0x0","XPC_SERVICE_NAME":"application.com.microsoft.VSCode.7715996.7716002","XPC_FLAGS":"0x0","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","VSCODE_CWD":"/","VSCODE_NLS_CONFIG":"{\"userLocale\":\"en-us\",\"osLocale\":\"en-us\",\"resolvedLanguage\":\"en\",\"defaultMessagesFile\":\"/Applications/Visual Studio Code.app/Contents/Resources/app/out/nls.messages.json\",\"locale\":\"en-us\",\"availableLanguages\":{}}","VSCODE_CODE_CACHE_PATH":"/Users/redacted/Library/Application Support/Code/CachedData/33fc5a94a3f99ebe7087e8fe79fbe1d37a251016","VSCODE_IPC_HOOK":"/Users/redacted/Library/Application Support/Code/1.97-main.sock","VSCODE_PID":"9192","ELECTRON_RUN_AS_NODE":"1","ELECTRON_NO_ATTACH_CONSOLE":"1","VSCODE_RESOLVING_ENVIRONMENT":"1"}
2025-02-10 08:29:36.415 [trace] getUnixShellEnvironment#shell /opt/homebrew/opt/powershell/bin/pwsh
2025-02-10 08:29:36.415 [trace] getUnixShellEnvironment#spawn ["-i","-l","-c"] '/Applications/Visual Studio Code.app/Contents/MacOS/Electron'  -p '"a6692e6a4343" + JSON.stringify(process.env) + "a6692e6a4343"'
2025-02-10 08:29:36.415 [info] update#setState idle
2025-02-10 08:29:36.415 [trace] [File Watcher (node.js)] Started watching: '/Users/redacted/Library/Application Support/Code/User'
2025-02-10 08:29:36.415 [trace] [File Watcher (node.js)] Started watching: '/Users/redacted/Library/Application Support/Code/User/settings.json'
2025-02-10 08:29:36.429 [trace] resolveShellEnv(): running (macOS/Linux)
2025-02-10 08:29:36.538 [trace] StorageMainService: creating workspace storage (1739191149929)
2025-02-10 08:29:36.539 [trace] getUnixShellEnvironment#raw 
2025-02-10 08:29:36.539 [trace] getUnixShellEnvironment#stderr �[31;1mParserError: �[0m
�[31;1m�[36;1mLine |�[0m
�[31;1m�[36;1m�[36;1m   1 | �[0m … lications/Visual Studio Code.app/Contents/MacOS/Electron'  �[36;1m-p�[0m '"a6692 …�[0m
�[31;1m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m     | �[31;1m                                                              ~~�[0m
�[31;1m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m�[31;1m�[31;1m�[36;1m     | �[31;1mUnexpected token '-p' in expression or statement.�[0m

2025-02-10 08:29:36.540 [error] Unable to resolve your shell environment: Unexpected exit code from spawned shell (code 1, signal null)
2025-02-10 08:29:36.641 [trace] window#load: window reported ready (id: 1)
2025-02-10 08:29:36.641 [trace] ElectronURLListener#flush(): flushing URLs
2025-02-10 08:29:36.656 [trace] menubarService#updateMenubar 1
2025-02-10 08:29:36.681 [trace] [SharedProcess] onWindowConnection for: vscode:createSharedProcessChannelConnectionResult
2025-02-10 08:29:36.682 [trace] [UtilityProcess type: shared-process, pid: <none>]: creating new...
2025-02-10 08:29:36.682 [trace] [UtilityProcess type: shared-process, pid: <none>]: payload sent via postMessage()
2025-02-10 08:29:36.682 [trace] [UtilityProcessWorker]: createWorker(window: 1, moduleId: vs/platform/files/node/watcher/watcherMain)
2025-02-10 08:29:36.683 [trace] [UtilityProcess id: 1, type: fileWatcher, pid: <none>]: creating new...
2025-02-10 08:29:36.683 [trace] [UtilityProcess type: shared-process, pid: 9217]: successfully created
2025-02-10 08:29:36.684 [trace] [UtilityProcess id: 1, type: fileWatcher, pid: 9218]: successfully created
2025-02-10 08:29:36.706 [trace] [UtilityProcess id: 1, type: extensionHost, pid: <none>]: creating new...
2025-02-10 08:29:36.707 [trace] [UtilityProcess id: 1, type: extensionHost, pid: 9219]: successfully created
2025-02-10 08:29:36.791 [trace] resolveShellEnv(): running (macOS/Linux)
2025-02-10 08:29:36.793 [error] ptyHost was unable to resolve shell environment Unable to resolve your shell environment: Unexpected exit code from spawned shell (code 1, signal null)
2025-02-10 08:29:36.796 [trace] [UtilityProcess type: ptyHost, pid: <none>]: creating new...
2025-02-10 08:29:36.797 [trace] PtyHostService#_startPtyHost 
    at ku.U (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:77:3012)
    at ku.h (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:77:1515)
    at get f (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:77:1465)
    at ku.reviveTerminalProcesses (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:77:6396)
    at Object.call (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:33:4564)
    at wf.s (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:31:19901)
    at wf.q (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:31:19424)
    at Ho.value (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:31:18826)
    at D.B (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:30:2373)
    at D.C (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:30:2443)
    at D.fire (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:30:2660)
    at Ho.value (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:28:4893)
    at D.B (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:30:2373)
    at D.fire (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:30:2591)
    at Ho.value (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:28:5077)
    at D.B (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:30:2373)
    at D.fire (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:30:2591)
    at T (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:28:7328)
    at IpcMainImpl.i (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/main.js:33:20534)
    at IpcMainImpl.emit (node:events:518:28)
    at WebContents.<anonymous> (node:electron/js2c/browser_init:2:85782)
    at WebContents.emit (node:events:518:28)
2025-02-10 08:29:36.798 [trace] [UtilityProcess type: ptyHost, pid: 9220]: successfully created
2025-02-10 08:29:36.809 [debug] Terminal profile not validated tmux ["tmux"]
2025-02-10 08:29:36.809 [debug] Terminal profile not validated fish ["fish"]
2025-02-10 08:29:36.839 [trace] [SharedProcess] IPC ready
2025-02-10 08:29:36.840 [trace] Main->SharedProcess#connect: connection established
2025-02-10 08:29:36.847 [trace] [File Watcher (node.js)] Request to start watching: /Users/redacted/Library/Application Support/Code/User (excludes: <none>, includes: <all>, filter: <none>, correlationId: <none>),/Users/redacted/Library/Application Support/Code/User/settings.json (excludes: <none>, includes: <all>, filter: <none>, correlationId: <none>)
2025-02-10 08:29:36.848 [trace] [File Watcher (node.js)] Started watching: '/Users/redacted/Library/Application Support/Code/User'
2025-02-10 08:29:36.849 [trace] [File Watcher (node.js)] Started watching: '/Users/redacted/Library/Application Support/Code/User/settings.json'
2025-02-10 08:29:36.854 [trace] [SharedProcess] Overall ready
2025-02-10 08:29:36.860 [trace] [File Watcher (node.js)] Request to start watching: /Users/redacted/.vscode/extensions (excludes: <none>, includes: <all>, filter: <none>, correlationId: <none>),/Users/redacted/.vscode/extensions/extensions.json (excludes: <none>, includes: <all>, filter: <none>, correlationId: <none>)
2025-02-10 08:29:36.861 [trace] [File Watcher (node.js)] Started watching: '/Users/redacted/.vscode/extensions'
2025-02-10 08:29:36.861 [trace] [File Watcher (node.js)] Started watching: '/Users/redacted/.vscode/extensions/extensions.json'
2025-02-10 08:29:37.096 [trace] [EncryptionMainService] Checking if encryption is available...
2025-02-10 08:29:37.120 [trace] [EncryptionMainService] Encryption is available:  true
2025-02-10 08:29:37.197 [trace] resolveShellEnv(): running (macOS/Linux)
2025-02-10 08:29:37.197 [error] resolving shell environment failed Unable to resolve your shell environment: Unexpected exit code from spawned shell (code 1, signal null)
2025-02-10 08:29:37.197 [trace] #1: https://update.code.visualstudio.com/api/update/darwin-universal/stable/33fc5a94a3f99ebe7087e8fe79fbe1d37a251016 - begin undefined {}
2025-02-10 08:29:37.200 [debug] ProxyResolver#loadSystemCertificates count 18
2025-02-10 08:29:37.200 [debug] ProxyResolver#loadSystemCertificates count filtered 14
2025-02-10 08:29:37.445 [trace] menubarService#updateMenubar 1
2025-02-10 08:29:37.626 [trace] #1: https://update.code.visualstudio.com/api/update/darwin-universal/stable/33fc5a94a3f99ebe7087e8fe79fbe1d37a251016 - end undefined 204 {"access-control-allow-origin":"*","date":"Mon, 10 Feb 2025 13:29:37 GMT","request-context":"appId=cid-v1:8109e553-6232-492a-afca-b78cea9b431c","strict-transport-security":"max-age=31536000; includeSubDomains","x-azure-ref":"20250210T132937Z-r199889546cnbkf8hC1BN1rw6w0000000vwg000000003f2h","x-cache":"CONFIG_NOCACHE","x-content-type-options":"nosniff","x-powered-by":"Express","x-source-commit":"ec889288e272a7cf2166c86c73aa9424bf003814"}
2025-02-10 08:29:37.822 [trace] menubarService#updateMenubar 1
2025-02-10 08:29:38.640 [trace] menubarService#updateMenubar 1
2025-02-10 08:29:38.793 [trace] resolveShellEnv(): running (macOS/Linux)
2025-02-10 08:29:38.793 [error] ptyHost was unable to resolve shell environment Unable to resolve your shell environment: Unexpected exit code from spawned shell (code 1, signal null)
2025-02-10 08:29:38.798 [debug] Terminal profile not validated fish ["fish"]
2025-02-10 08:29:38.798 [debug] Terminal profile not validated tmux ["tmux"]
2025-02-10 08:29:38.861 [trace] lifecycle (main): phase changed (value: 4)
2025-02-10 08:29:39.467 [trace] menubarService#updateMenubar 1
2025-02-10 08:29:40.483 [trace] menubarService#updateMenubar 1
2025-02-10 08:30:06.365 [trace] update#checkForUpdates, state =  idle
2025-02-10 08:30:06.365 [info] update#setState checking for updates
2025-02-10 08:30:06.670 [info] update#setState idle
2025-02-10 08:33:48.703 [trace] menubarService#updateMenubar 1
2025-02-10 08:33:52.323 [trace] menubar#runActionInRenderer {"type":"commandId","commandId":"workbench.action.showAboutDialog"}
2025-02-10 08:40:01.171 [trace] menubarService#updateMenubar 1

Note the following:

2025-02-10 08:29:36.415 [trace] getUnixShellEnvironment#shell /usr/local/bin/pwsh
2025-02-10 08:29:36.415 [trace] getUnixShellEnvironment#spawn ["-i","-l","-c"] '/Applications/Visual Studio Code.app/Contents/MacOS/Electron'  -p '"a6692e6a4343" + JSON.stringify(process.env) + "a6692e6a4343"'

Why is VS Code trying to pass -ilc to pwsh (and therefore miss the conditional branch that avoids this very issue)?

Metadata

Metadata

Assignees

Labels

author-verification-requestedIssues potentially verifiable by issue authorbugIssue identified by VS Code Team member as probable bugimportantIssue identified as high-priorityverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions