【问题标题】:Visual Studio (VS-code) code terminal is failing to launchVisual Studio (VS-code) 代码终端无法启动
【发布时间】:2020-08-01 07:31:14
【问题描述】:

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

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

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

下面是我的 vscode 的 JSON 文件

{
    "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": [
    
    ]
}

查看此链接以获取完整的错误描述,我编写代码并编译并收到错误消息。 link

【问题讨论】:

  • 你是从哪里编译的?.from vs code 终端还是你系统的终端?
  • 你能补充更多细节吗?
  • @Maghilvannan 来自我编译的 Vs 代码
  • @Piyush 不管我提到了兄弟,我无法添加图片,所以发布了一个与我的错误相同的图片链接。 link
  • 分享vscode的设置(JSON)文件。

标签: visual-studio-code


【解决方案1】:

此设置破坏了我的终端窗口(因为 powershell 因公司管理员而被阻止):

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

将 CMD 恢复为默认值

在 VS Code 设置中更改路径:

  • 打开首选项 > 设置 (CTRL+,)
  • 搜索terminal.integrated.shell.windows
  • (其他操作系统将windwos 替换为linuxosx

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

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

2021 年 9 月更新(附加设置)

搜索 terminal.integrated.defaultProfile.windows 并设置默认值(对我来说是命令提示符)

【讨论】:

    【解决方案2】:

    您似乎正在尝试在 VS Code 集成终端上获取 Powershell。

    让我分享一下我是如何做到的。

    1. 打开 VS 代码
    2. 转到文件 > 首选项 > 设置
    3. 在搜索栏中输入“终端”
    4. 在功能下>点击“终端”
    5. 向下滚动直到找到这样的部分并确保该选项为空(这将设置默认起始目录):

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

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

    终端 › 集成 › 外壳: Windows 终端在 Windows 上使用的 shell 的路径(默认:

    1. 点击编辑 settings.json

    2. 将您的终端绝对路径粘贴在括号内(确保您避开斜杠),这就是我使用双精度的原因

    “终端.integrated.shell.windows”: "C:\\InstallationDirectory\\PowerShell\\7\\pwsh.exe"

    享受

    【讨论】:

      【解决方案3】:

      仅供参考 当我用 3 字节字符命名我的父目录时,我遇到了同样的问题。将目录名称更改为按字母顺序排列以解决问题。

      【讨论】:

        【解决方案4】:

        我在连接到 Linux 远程的 Windows 上运行 VS Code 时遇到了同样的问题。这可能发生在我之前的会话期间,我删除了远程上的一个目录,现在它正试图在这个目录中启动一个 shell。简单地重新创建目录(一个空目录)为我解决了这个问题。

        【讨论】:

        • 这个帮我解决了!
        【解决方案5】:

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

        1. 安装 git bash.... 链接 (https://git-scm.com/downloads)。
        2. 打开 settings.json 文件。将终端的路径更改为您安装 git-bash 的位置。 即在“terminal.integrated.shell.windows”中:
          例如:- “terminal.integrated.shell.windows”:“C:\Program Files\Git\git-bash.exe” 就我而言。注意:- 路径包含双反斜杠(\ \)。
        3. 按 ctrl+`。外部终端在当前目录打开。
        4. 现在编译您的代码 :)

        【讨论】:

        • 感谢帮助,但问题仍然存在。
        • 同样的错误兄弟,以前发生过。即使在卸载并再次安装后问题仍然存在。我很沮丧,因为我更喜欢 vscode。
        • 我建议安装 git-bash.... 不卸载 vscode 并重新安装
        • 首先,我按照你的建议做了,然后我尝试卸载和安装。
        【解决方案6】:

        在我的 Mac 上遇到了同样的问题。 通过添加解决它

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

        settings.json

        【讨论】:

        • 我想知道这个答案有什么帮助,因为问题是关于 Windows 上的代码。
        【解决方案7】:

        如果您在 Windows 上,在执行任何这些步骤之前尝试执行完全关闭或重新启动。

        按住 shift 键并从起始行关闭或重新启动您的电脑。

        多次帮助找回终端。

        【讨论】:

        • 我希望你的意思是讽刺 ;-)
        【解决方案8】:

        我收到此错误“终端进程无法启动:shell 可执行文件“C:\Program Files\PowerShell\7\pwsh.exe”的路径不存在” 我注意到我没有安装powershell 7,因为我已经安装了这个错误已经解决

        或者如果我们想继续使用我们系统上的相同 Powershell,那么我们必须通过编辑 jason 文件来更改路径 设置>terminal.integrated.shell.windows>在setting.jason中编辑 enter image description here

        注释掉 "terminal.integrated.shell.windows": "C:\Program Files\PowerShell\7\pwsh.exe",并取消注释 "terminal.integrated.shell.windows": "C:\WINDOWS\System32 \WindowsPowerShell\v1.0\powershell.exe", enter image description here

        【讨论】:

          【解决方案9】:

          我可以通过将"type": "shell" 添加到任务中来解决此问题。似乎默认值为"type": "process",这并没有让任务运行。进程类型需要此处概述的 windows/command 结构:https://code.visualstudio.com/docs/editor/tasks#_operating-system-specific-properties

          【讨论】:

            【解决方案10】:

            转到 Visual Studio Code 的设置并禁用此属性 powershell.integratedConsole.suppressStartupBanner。它对我有用。我使用的是 VS 代码版本 1.62.3

            【讨论】:

              【解决方案11】:

              有时在 VS CODE 中,命令提示符的默认配置文件路径会不匹配,导致无法启动终端。

              解决方案 1:尝试更正此路径: "terminal.integrated.shell.windows": "C:\Windows\System32\cmd.exe".

              解决方案 2:

              ctrl+p打开setting.json文件,

              找到这一行:terminal.integrated.shell.windows": "C:\Windows\System32\cmd.exe 并使用以下配置进行更新,

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

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 2021-05-26
                • 1970-01-01
                • 1970-01-01
                • 2020-01-12
                • 1970-01-01
                相关资源
                最近更新 更多