...
git-bash.exe
是一个Windows应用程序(入口为WinMain),而bash.exe
是一个控制台应用程序(入口为main)。要将其用作集成式shell,可执行文件必须是控制台应用程序,以便可以重定向stdin/stdout/stderr。
建议的方法是使用:
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
实际上,我正在寻找解决这个确切问题的方法。@JBD说得很正确,但我想补充一点,即git-bash.exe文件被保留在git的正常程序文件夹中。
{
"terminal.integrated.shell.windows": "D:\\Program Files\\Git\\git-bash.exe"
}
但是,在vs Code的设置中需要链接的是另一个文件,它将使git bash在vs code终端中运行。该文件的路径位于“Git”文件夹内的“bin”文件夹中。
{
"terminal.integrated.shell.windows": "D:\\Program Files\\Git\\bin\\bash.exe"
}
我遇到了同样的问题,但是接受的答案在最新版本的VSCode上已经不再适用(我正在使用1.74.3)。它会抛出类似下面的错误。
这已经过时了,配置默认shell的新推荐方式是通过创建终端配置文件在
#terminal.integrated.profiles.windows#
并将其配置文件名称设置为默认值在#terminal.integrated.defaultProfile.windows#
。目前这将优先于新的配置文件设置,但这将来会改变。
问题是,在Git中有两种类型的bash应用程序:
bash.exe位于/bin文件夹内。
它需要在settings.json中进行以下配置
"terminal.integrated.profiles.windows": {
"Bash": {
"path": "C:\\Program Files\\Git-2.35.1.2\\bin\\bash.exe"
}
}
我也遇到了这个问题,但我解决了它。
更改 Git Bash 的路径:
"terminal.integrated.shell.windows": "D:\Program Files\Git\bin\bash.exe"
并在 cmd 中取消勾选旧版控制台复选框 cmd 图片
对于那些使用通过Scoop安装的Git的用户,只需使用Scoop的安装文件夹路径:
"terminal.integrated.shell.windows": "${env:USERPROFILE}\\scoop\\apps\\git\\current\\bin\\bash.exe",
不确定所有情况,但在我的情况下,Git Bash的位置已更改为appdata而不是编程文件,因此您可以使用与所述相同的方法:
"terminal.integrated.shell.windows": "C:\\Users\\{user_name}\\AppData\\Local\\Programs\\Git\\bin\\bash.exe",