maritochapin
maritochapin

Reputation: 121

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

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

Upvotes: 9

Views: 9635

Answers (5)

Oussama ELJabbari
Oussama ELJabbari

Reputation: 115

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.

Upvotes: 2

HIMYM
HIMYM

Reputation: 31

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

Upvotes: 3

Thameur Daly
Thameur Daly

Reputation: 319

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

Upvotes: 0

Rohit Kumar Yadav
Rohit Kumar Yadav

Reputation: 11

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.

Upvotes: 1

maritochapin
maritochapin

Reputation: 121

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.

Upvotes: 3

Related Questions