22

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

11
  • from where did you compile it?.from vs code terminal or your system's terminal? Aug 1, 2020 at 7:41
  • Can you add more details?
    – user5889334
    Aug 1, 2020 at 8:05
  • @Maghilvannan from Vs code i compiled
    – mr. abhi
    Aug 1, 2020 at 9:37
  • @Piyush Whatever was showing i mentioned bro,i can't add the picture so posting a link of picture which has same error as mine. link
    – mr. abhi
    Aug 1, 2020 at 9:38
  • share the settings(JSON) FILE of vscode.
    – vinod
    Aug 1, 2020 at 10:40

13 Answers 13

44

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 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.

2
  • 1
    this is the best answer among all the other....
    – LeMarque
    Aug 20, 2022 at 6:08
  • thank you, this solution worked for me..
    – rishi jain
    Sep 2 at 14:55
4

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"

1

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.

1
  • What are "3byte characters"? Do you mean UTF-8 byte sequences? (E.g., 0xE2 0x80 0x94 for Unicode code point U+2014 (EM DASH)) Jun 21 at 14:19
1

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.

1
  • This one solved it for me!
    – Retrax
    Dec 16, 2021 at 5:57
1

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 :)
4
  • thanks for the help man but problem still persists.
    – mr. abhi
    Aug 1, 2020 at 14:16
  • same error bro ,which was happening before.Even after uninstalling and again installing problem persists.I am frustrated as i liked vscode more.
    – mr. abhi
    Aug 2, 2020 at 3:33
  • i suggested to install git-bash.... not uninstalling vscode and again installing
    – vinod
    Aug 2, 2020 at 4:34
  • firstly, i did what u suggested man after that i tried uninstalling and installing.
    – mr. abhi
    Aug 2, 2020 at 12:13
1

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

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

in file settings.json.

1
  • 2
    I wonder how this answer could help, as the question is about Code on Windows. Mar 6, 2022 at 9:16
0

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

0

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.

0

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

0

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.

1
  • 1
    I hope you meant that sarcastically ;-) Mar 6, 2022 at 9:17
0

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",
0

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!

-1

Why is Visual Studio Code terminal failing at launch?

The Visual Studio Code terminal can fail when launching due to the fact that your default terminal was being launched through the properties of the program as an administrator automatically (please, check the hyperlink image below):

Right click PowerShell → Properties → Compatibility → "Run this program as an administrator"

How do I solve it?

If you have this option checked, it's as simple as to uncheck it, apply, and accept.

Please, keep in mind that after you do this, each time in the future that you want to open your terminal it won't be opened anymore as an administrator automatically. You'll have to do it manually by right clicking your program, and selecting the option "Run as Administrator".

1
  • 1
    (Despite its weird form, this answer was probably not plagiarised, ChatGPT or otherwise.) Jun 21 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.