mr. abhi
mr. abhi

Reputation: 301

Visual Studio Code terminal is failing to launch

I tried to compile a program, but the terminal is not opening.

error:The terminal process failed to launch: Starting directory (cwd) "D:\vs code\march long 2020" does not exist.

This guy has the same error, but the pop-up is different link.

Below is the JSON file of my Visual Studio Code:

{
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "C_Cpp.updateChannel": "Insiders",
    "files.autoSave": "afterDelay",
    "java.saveActions.organizeImports": true,
    "window.zoomLevel": 0,
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
    "terminal.integrated.windowsEnableConpty": false,
    "json.schemas": [

    ]
}

See this link for full error description. I wrote code and compiled and got an error message.

Link

Upvotes: 28

Views: 152056

Answers (15)

grandmaestr
grandmaestr

Reputation: 169

I had a similar issue while running VS Code with WSL (Windows Subsystem for Linux). I was getting the following error

The terminal process failed to launch: Starting directory (cwd) "/home/username" does not exist.

I resolved it by adding

"terminal.integrated.cwd": "//wsl.localhost/Ubuntu/home/username",

Reload VS Code and try again You can change the path to any directory you want - the "//wsl.localhost/Ubuntu" prefix is what's important. Change "Ubuntu" to the name of the distribution you are using (in Windows PowerShell, run wsl --list to see the installed distributions).

Upvotes: 0

tom
tom

Reputation: 10601

This setting breaks my terminal window (because PowerShell is blocked due company administrative policy):

Enter image description here

Afterwards, I could not open the terminal again.

Restore CMD as default

  • open File > Preferences > Settings (CTRL+,)
  • search for terminal.integrated.defaultProfile.windows and set a default (for me Command Prompt)

Enter image description here

Now the terminal should open again. This is not a fix to get PowerShell working in Visual Studio Code, just a guide to restore the terminal window.

Upvotes: 56

Brijesh Ray
Brijesh Ray

Reputation: 1303

PROBLEM:

I got following error while opening VS Code terminal:

"
The terminal process failed to launch: Windows cannot open this program because it has been prevented by a software restriction policy.
For more information, open Event Viewer or contact your system Administrator.
"

enter image description here

REASON OF ERROR:

Following is the reason of error where Integrated>Default Profile: Windows is NULL (It should be command prompt)

enter image description here

SOLUTION:

In VS code -->settings-->Features-->Terminal-->Integrated>Default Profile: Windows ---select command prompt as default

Changed Integrated>Default Profile: Windows ---from NULL to command prompt as default

enter image description here

Now Restart visual studio and open terminal again.

Upvotes: 0

Niuq
Niuq

Reputation: 331

If anyone having the issue with split terminal failing to launch terminal due to The terminal process failed to launch: Starting directory (cwd).

enter image description here

It works for me by changing the Terminal › Integrated: Split Cwd or terminal.integrated.splitCwd to initial or workspaceRoot.

The error caused might be due to the path location given by your chosen shell. I am using Git Bash on Windows with Oh My ZSH, the error showed up after setting up the ZSH.

Upvotes: 2

jonask
jonask

Reputation: 748

I had the same issue on my Mac. I solved it by adding

"terminal.integrated.shell.osx": "/bin/bash"

in file settings.json.

Upvotes: 2

Patrick Makanga
Patrick Makanga

Reputation: 1

I really struggled with this issue when creating a new project with Maven and I later realized the issue was with restriction on my profile folder as the machine belongs to the company.

I decided to uninstall Visual Studio Code as by default its usually installed under C:\Users\ProfileName\AppData\Local\Programs\Microsoft VsCode and re-install it as an administrator. Guide to completely install Visual Studio Code is on page How can I uninstall Visual Studio Code completely?

To install Visual Studio Code as administrator you have to download the System Installer version (NOT the default one with a big blue button). Once downloaded, run it as administrator and the installation will be directed to the programs folders as opposed to the user profile folder...enjoy!

Upvotes: 0

Suresh B B
Suresh B B

Reputation: 1420

Sometimes in Visual Studio Code, its default profile path of the command prompt will be mismatched so for that reason it is unable to launch the terminal.

Solution 1: try correct it with this path: "terminal.integrated.shell.windows": "C:\Windows\System32\cmd.exe".

or

Solution 2:

Enter image description here

Press Ctrl + P to open the settings.json file.

Find the line: terminal.integrated.shell.windows": "C:\Windows\System32\cmd.exe and update with the below configuration,

 "terminal.integrated.profiles.windows": {
        "my-pwsh": {
          "source": "PowerShell",
          "args": ["-NoProfile"]
        }
      },
    //"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
    "terminal.integrated.defaultProfile.windows": "Command Prompt",

Upvotes: 0

ibnz developers
ibnz developers

Reputation: 1

If you on Windows, before doing any of those steps, try to perform a Full Shut down or Restart.

Press and hold the Shift key and shut down or restart your PC from the start menu.

It helped to get terminal back many times.

Upvotes: 0

Edward Casanova
Edward Casanova

Reputation: 1064

It appears that you're trying to get PowerShell in a Visual Studio Code integrated terminal.

Let me share the process of how I did it.

  1. Open Visual Studio Code
  2. Go to menu FilePreferencesSettings
  3. Type "Terminal" in the search bar
  4. Under Features, click on "terminal"
  5. Scroll down until you find a section like this and make sure the option is empty (this sets a default starting directory):

Terminal › Integrated: Cwd
An explicit start path where the terminal will be launched, this is used as the current working directory (cwd) for the shell process.
This may be particularly useful in workspace settings if the root directory is not a convenient cwd.

  1. Scroll down until you find this other option

Terminal › Integrated › Shell: Windows
The path of the shell that the terminal uses on Windows (default:

  1. Click on edit settings.json

  2. Paste your terminal absolute path within the brackets (make sure you escape the slashes). That's the reason of why I'm using double

"terminal.integrated.shell.windows": "C:\\InstallationDirectory\\PowerShell\\7\\pwsh.exe"

Upvotes: 7

vinod
vinod

Reputation: 796

I also faced the same issue, but I was not able to find a solution.I got a different fix for that..

  1. Install Git Bash. Download link.
  2. Open the settings.json file. change the path of terminal to where you installed Git Bash. i.e., in "terminal.integrated.shell.windows": eg:- "terminal.integrated.shell.windows": "C:\Program Files\Git\git-bash.exe" in my case. NOTE:- the path contains double back slash(\ \).
  3. press Ctrl + `. An external Terminal opens on the current directory.
  4. now compile your code :)

Upvotes: 1

Sachin
Sachin

Reputation: 111

Go to the setting of Visual Studio Code and disable this property powershell.integratedConsole.suppressStartupBanner. It worked for me.I am using VS code version 1.62.3 enter image description here

Upvotes: 0

tagyoureit
tagyoureit

Reputation: 1286

I was able to fix this by adding "type": "shell" to the task. It seems that the default is "type": "process" and that wasn't letting the task run. The process type would need the windows/command structure as outlined here: https://code.visualstudio.com/docs/editor/tasks#_operating-system-specific-properties.

Upvotes: 0

user16710913
user16710913

Reputation: 1

I was getting this error "The terminal process failed to launch: Path to shell executable "C:\Program Files\PowerShell\7\pwsh.exe" does not exist" What i noticed i have not installed powershell 7 as i have installed this error has been resolved

or if we want to continue with same Powershell what we have on our system then we have to change the path By editing the jason file setting>terminal.integrated.shell.windows>Edit in setting.jason enter image description here

comment out "terminal.integrated.shell.windows": "C:\Program Files\PowerShell\7\pwsh.exe", and uncomment "terminal.integrated.shell.windows": "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe", enter image description here

Upvotes: 0

Basileios
Basileios

Reputation: 325

I had the same issue with VS Code running on Windows connecting to a Linux remote. It probably occurred since during my previous session I deleted a directory on the remote and now it was trying to start a shell in this directory. Simply recreating the directory (an empty one) solved the problem for me.

Upvotes: 3

shrskn
shrskn

Reputation: 33

FYI I faced the same issue when I named my parent directory in 3byte characters. Changed the directory name to alphabetical to resolve the issue.

Upvotes: 1

Related Questions