尝试将 Git Bash 设置为终端的默认配置文件时,设置中出现 VSCode 错误 [英] VSCode error in settings when trying to set Git Bash as default profile for terminal

查看:49
本文介绍了尝试将 Git Bash 设置为终端的默认配置文件时,设置中出现 VSCode 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将 Git Bash 设置为 VSCode 中的默认终端,但无法成功.我试过关注下一篇文章:

  1. 有人知道如何解决这个问题吗?

    我的 VsCode 版本:

    版本:1.57.1​​(用户设置)提交:507ce72a4466fbb27b715c3722558bb15afa9f48日期:2021-06-17T13:28:07.755Z电子:12.0.7铬:89.0.4389.128Node.js:14.16.0V8:8.9.255.25-electron.0操作系统:Windows_NT x64 10.0.19042

    我使用 git SDK,类似于 git-bash 但不完全是.也许这就是问题所在?

    解决方案

    我刚刚遇到了同样的问题.我的 VS Code 1.60.0 上的解决方案也是将 Git Bash 重命名为 GitBash.

    在使用 Developer Tools 进行调试时,我发现 VS Code 总是合并";对象值具有相同键的默认值,因此:

    • 在 VS Code 中,Git Bash 键的默认值为 { source: Git Bash";}
    • 我曾经写过 {..., "Git Bash": { "path": "D:\\Git\\usr\\bin\\bash.exe", ... }}
    • 然后合并的值是 {..., "Git Bash": { "source": "Git Bash", "path": "...", ...}}
    • 在名为 showProfileQuickPick 的函数中,VS Code 调用 _detectProfiles
      • 此函数将terminal.integrated.profiles.windowsterminal.integrated.defaultProfile.windows 的值发送到其_primaryOffProcessTerminalService
      • profiles 的值只是合并后的值
    • 因此,Git Bash 的对象在某种程度上是非法的";然后忽略

    相反,GitBash 的意思是声明一个新的配置文件对象,所以它应该可以工作.

    I tried to set Git Bash as the default terminal in VSCode, but I can't do it successfully. I've tried following the next articles:

    1. How do I use Bash on Windows from the Visual Studio Code integrated terminal?
    2. How to Add Git Bash to VsCode

    But they haven't resolved my issue.

    I managed to generate profiles in settings.json, but Git Bash doesn't work for some reason unknown to me and VsCode shows an error.

    My settings.json:

    {
        "terminal.integrated.profiles.windows": {
            "PowerShell": {
                "source": "PowerShell",
                "icon": "terminal-powershell"
            },
            "Command Prompt": {
                "path": [
                    "${env:windir}\\Sysnative\\cmd.exe",
                    "${env:windir}\\System32\\cmd.exe"
                ],
                "args": [],
                "icon": "terminal-cmd"
            },
            "Git Bash": {
                "source": "Git Bash",
                "path": "C:\\git-sdk-64\\git-bash.exe",
                "args": [
                    "--login",
                    "-i"
                ]
            },
            "Cygwin": {
                "path": "C:\\cygwin64\\bin\\bash.exe",
                "args": [
                    "--login"
                ]
            }
        },
        "terminal.integrated.defaultProfile.windows": "Git Bash"
    }
    

    The error:

    Does anyone know how to fix this?

    My VsCode version:

    Version: 1.57.1 (user setup)
    Commit: 507ce72a4466fbb27b715c3722558bb15afa9f48
    Date: 2021-06-17T13:28:07.755Z
    Electron: 12.0.7
    Chrome: 89.0.4389.128
    Node.js: 14.16.0
    V8: 8.9.255.25-electron.0
    OS: Windows_NT x64 10.0.19042
    

    Edit:

    I use git SDK, which is like git-bash but not exactly. Maybe this is the problem?

    解决方案

    I just met a same problem. And the solution on my VS Code 1.60.0 is also to rename Git Bash into GitBash.

    During debugging using Developer Tools, I found VS Code always "merge" object values with the default values of a same key, so:

    • in VS Code, the Git Bash key has a default value of { source: "Git Bash" }
    • I once wrote {..., "Git Bash": { "path": "D:\\Git\\usr\\bin\\bash.exe", ... }}
    • and then the merged value is {..., "Git Bash": { "source": "Git Bash", "path": "...", ... }}
    • during a function named showProfileQuickPick, VS Code calls _detectProfiles
      • this function sends values of terminal.integrated.profiles.windows and terminal.integrated.defaultProfile.windows to its _primaryOffProcessTerminalService
      • the value of profiles is just the merged one
    • as a result, the object of Git Bash is somehow "illegal" and then ignored

    On the contrary, GitBash means to declare a new profile object, so it should work.

    这篇关于尝试将 Git Bash 设置为终端的默认配置文件时,设置中出现 VSCode 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆