Visual Studio (VS-code) 代码终端无法启动

mr.*_*bhi 10 visual-studio-code

我试图编译一个程序,但终端没有打开。

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

这家伙有同样的错误,但弹出窗口是不同的链接

下面是我的 vscode 的 JSON 文件

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

请参阅此链接以获取完整的错误描述,我编写了代码并编译并收到了错误消息。 关联

kmg*_*mgt 19

与我将 VS Code 中的默认 shell 更改为 Powershell 时遇到了同样的问题。在我的情况下,由于公司管理员,powershell 被阻止。

此设置打破了我的终端窗口: 在此处输入图片说明

之后我无法再次打开终端。

要再次将 CMD 设为默认值,我必须更改 VS Code 设置中的路径:

  • 打开首选项 > 设置 (CTRL+,)
  • 搜索 terminal.integrated.shell.windows

在此处输入图片说明

  • 点击 Edit in settings.json
  • 设置CMD路径 "terminal.integrated.shell.windows": "C:\\windows\\System32\\cmd.exe",

在此处输入图片说明

现在终端应该再次打开。这不是让 Powershell 在 VS Code 中工作的修复,只是恢复终端窗口的指南。


Edw*_*ova 6

您似乎正在尝试在 Visual Studio Code 集成终端中获取 PowerShell。

\n

我来分享一下我是如何做到的过程。

\n
    \n
  1. 打开 Visual Studio 代码
  2. \n
  3. 转到菜单文件\xe2\x86\x92首选项\xe2\x86\x92设置
  4. \n
  5. 在搜索栏中输入“终端”
  6. \n
  7. “功能”下,单击“终端”
  8. \n
  9. 向下滚动,直到找到这样的部分,并确保该选项为空(这会设置默认的起始目录):
  10. \n
\n
\n

终端 \xe2\x80\xba 集成:Cwd
\n将启动终端的显式启动路径,用作 shell 进程的当前工作目录 (cwd)。
\n如果根\n目录不是一个方便的 cwd,这在工作区设置中可能特别有用。

\n
\n
    \n
  1. 向下滚动,直到找到其他选项
  2. \n
\n
\n

终端 \xe2\x80\xba 集成 \xe2\x80\xba Shell: Windows
\n终端在 Windows 上使用的 shell 的路径(默认值:

\n
\n
    \n
  1. 单击编辑settings.json

    \n
  2. \n
  3. 将终端绝对路径粘贴到括号内(确保转义斜杠)。这就是我使用 double 的原因

    \n
  4. \n
\n
\n

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

\n
\n


vin*_*nod 1

我也遇到了同样的问题,但我无法找到解决方案。我为此找到了不同的解决方案。

  1. 安装Git Bash下载链接
  2. 打开settings.json 文件。将终端路径更改为安装 Git Bash 的位置。即,在“terminal.integrated.shell.windows”中:例如:-“terminal.integrated.shell.windows”:“C:\ Program Files \ Git \ git-bash.exe”在我的情况下。注意:- 路径包含双反斜杠(\ \)。
  3. Ctrl+ `。外部终端将在当前目录中打开。
  4. 现在编译你的代码:)