Error message when loading VS Code Unable to resolve your shell environment: A system error occured(spawn/user/bin/zsh ENOENT
Asked Answered
C

5

9

Hi I am running Ubuntu 20.04 I used to have zsh installed and oh-my-zsh I have uninstalled them both and now when I start vs code using the GUI from my Desktop I receive the following error message with screenshot below

Unable to resolve your shell environment: A system error occured(spawn/user/bin/zsh ENOENT

Screenshot when VS Code Loads:

Screenshot when VS Code Loads

I have gone into the settings for vs code in default profile for linux and have set it to bash

default profile linux set to bash

when I open up vs code from the terminal by running the command code . I do not receive this error since I am in a bash terminal. I have been looking around all over to find where does vs code look for a .zsh path when loading from the GUI. thank you.

Edit: here is my settings.json

{
  "terminal.integrated.tabs.enabled": true,
  "files.trimTrailingWhitespace": true,
  "files.insertFinalNewline": true,
  "files.trimFinalNewlines": true,
  "editor.tabSize": 2,
  "[html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
  },
  "editor.formatOnSave": true,
  "liveServer.settings.CustomBrowser": "chrome",
  "update.mode": "none",
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "liveServer.settings.host": "localhost",
  "window.zoomLevel": 3,
  "files.autoSave": "afterDelay",
  "editor.minimap.enabled": false,
  "terminal.integrated.automationProfile.linux": {

  },
  "terminal.integrated.defaultProfile.linux": "bash",
  "terminal.integrated.profiles.linux": {
    
    "bash": {
      "path": "bash",
      "icon": "terminal-bash"
    },
    "fish": {
      "path": "fish"
    },
    "tmux": {
      "path": "tmux",
      "icon": "terminal-tmux"
    },
    "pwsh": {
      "path": "pwsh",
      "icon": "terminal-powershell"
    }
  },
  "terminal.integrated.defaultProfile.osx": ""
}

also included a error message I am getting for line 21 at

"terminal.integrated.automationProfile.linux": {

  },

error message on line 21:

error message on line 21

line 20 through 21 has mark for error:

line 20 through 21 has mark for error

Coenurus answered 17/12, 2022 at 0:35 Comment(5)
Can you post your settings JSON ?Sophey
@TimothyG. thank you for the response I have edited my post to include the settings.JSON from vs code.Coenurus
SOLVED: ` sudo chsh -s /usr/bin/bash` then when I check what is my shell by running echo $SHELL The error is no longer appearing.Coenurus
Credit to github.com/microsoft/vscode/issues/…Coenurus
$SHELL changed for me after editing the shell path directly in the etc/passwd file for my user. chsh -s or usermod -s didn't work for me.Afraid
C
3

Based on this vscode issue comment:

sudo chsh -s /usr/bin/bash

then when I check what is my shell by running

echo $SHELL

it now points to /usr/bin/bash

The error is no longer appearing when launching VS Code from GUI.

Coenurus answered 18/12, 2022 at 3:32 Comment(1)
In my case, /usr/bin/bash should be changed to /bin/bashPart
H
2

if this is your issue

Changing the desktop file of vs code like this, worked for me!:


    #Exec=/usr/share/code/code --unity-launch %F
    Exec=/usr/bin/code

you may need to figure out where the desktop file stored depending on how you installed vs code.

Haines answered 15/9, 2023 at 14:6 Comment(0)
N
1

simple solution of the above error! is to again install the zsh using: sudo apt install zsh -y no need to do anything just restart the Vs code after running the above code in your command bash.

Natachanatal answered 25/8, 2023 at 17:9 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Dreamy
C
1

I had the exact same issue.

I ended up solving the issue by creating a symbolic link from the path VS Code is checking (/usr/local/bin/zsh in my case) to the zsh path (the path you see when you run which zsh. It was /opt/homebrew/bin/zsh in my case).

So I ran the following command and it worked. sudo ln -s /opt/homebrew/bin/zsh /usr/local/bin/zsh

Counterpoint answered 12/11, 2023 at 15:11 Comment(0)
D
0

The process outlined below may help you identify which parts of your shell initialization are taking the most time:

  • Open your shell's startup file (for example, in VS Code by typing ~/.bashrc or ~/.zshrc in Quick Open (⌘P)).
  • Selectively comment out potentially long running operations (such as nvm if you find that).
  • Save and fully restart VS Code.
  • Continue commenting out operations until the error disappears.

Worked for me

Source

Deeannadeeanne answered 29/8, 2023 at 14:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.