Windows: VSCode git在git-bash终端shell中现在无法使用,自2024年3月起可以正常工作,

m1m5dgzv  于 3个月前  发布在  Vscode
关注(0)|答案(4)|浏览(72)

这个问题在所有扩展都被禁用时是否发生?:是/否

  • VS Code 版本:Bug 首次出现在 2024 年 4 月。2024 年 3 月是最后一个正常工作的版本
  • OS 版本:Windows 10(最新)

重现步骤:

  1. git clone https://github.com/zackees/zcmds && cd zcmds
  2. 使用 2024 年 5 月或 4 月的 VSCode
  3. 将命令提示符设置为 git-bash
  4. 输入 git status
    结果:
Zach Vorhies@DESKTOP-I3718DO MINGW64 C:/Users/niteris/AppData/Local/Programs/Microsoft VS Code
$ git status
fatal: unable to access 'C:\Users
iteris/.config/git/config': Invalid argument
$ env
ProgramFiles(x86)=C:\Program Files (x86)
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
NUMBER_OF_PROCESSORS=16
COLORTERM=truecolor
PROCESSOR_LEVEL=23
PYTHONUNBUFFERED=1
CYGWIN=mintty
TERM_PROGRAM_VERSION=1.90.2
USERDOMAIN_ROAMINGPROFILE=DESKTOP-I3718DO
ChocolateyToolsLocation=C:\tools
PROGRAMFILES=C:\Program Files
MSYSTEM=MINGW64
ChocolateyInstall=C:\ProgramData\chocolatey
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW
JAVA_HOME=C:\Users\niteris\dev\androidmonitor-client\FlutterSDK\java\jdk-20.0.2
OS=Windows_NT
HOMEDRIVE=C:
USERDOMAIN=DESKTOP-I3718DO
PWD=C:/Users/niteris/AppData/Local/Programs/Microsoft VS Code
USERPROFILE=C:\Users\niteris
TESSDATA_PREFIX=C:\Program Files (x86)\Tesseract-OCR\
VSCODE_GIT_ASKPASS_NODE=C:\Users\niteris\AppData\Local\Programs\Microsoft VS Code\Code.exe
ALLUSERSPROFILE=C:\ProgramData
CommonProgramW6432=C:\Program Files\Common Files
HOME=C:\Users
iteris
USERNAME=Zach Vorhies
LANG=en_US.UTF-8
VBOX_MSI_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\
PLINK_PROTOCOL=ssh
OneDrive=C:\Users\Zach Vorhies\OneDrive
VIRTUAL_ENV=C:\Users
iteris\dev\zcmds♂env
COMSPEC=C:\Windows\system32\cmd.exe
GIT_ASKPASS=c:\Users\niteris\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\git\dist\askpass.sh
APPDATA=C:\Users\niteris\AppData\Roaming
SYSTEMROOT=C:\Windows
LOCALAPPDATA=C:\Users\niteris\AppData\Local
COMPUTERNAME=DESKTOP-I3718DO
VSCODE_GIT_ASKPASS_EXTRA_ARGS=
ANDROID_HOME=C:\Users\niteris\dev\androidmonitor-client\FlutterSDK\Android\sdk
TERM=xterm-256color
LOGONSERVER=\\DESKTOP-I3718DO
PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
NVTOOLSEXT_PATH=C:\Program Files\NVIDIA Corporation\NvToolsExt\
VSCODE_GIT_IPC_HANDLE=\\.\pipe\vscode-git-ec5c4ae3b2-sock
PYTHONIOENCODING=utf-8
TEMP=/tmp
SHLVL=1
PROCESSOR_REVISION=7100
DriverData=C:\Windows\System32\Drivers\DriverData
ANDROID_SDK_ROOT=C:\Users\niteris\dev\androidmonitor-client\FlutterSDK\Android\sdk
NVAFX_SDK_DIR=C:\Program Files\NVIDIA Corporation\NVIDIA Audio Effects SDK
VIRTUAL_ENV_PROMPT=(venv)
COMMONPROGRAMFILES=C:\Program Files\Common Files
EXEPATH=C:\Program Files\Giin
PROCESSOR_IDENTIFIER=AMD64 Family 23 Model 113 Stepping 0, AuthenticAMD
FlutterSKDPATH=C:\Users\niteris\dev\androidmonitor-client\FlutterSDK\flutter\bin;C:\Users\niteris\dev\androidmonitor-client\FlutterSDK\ant\apache-ant-1.10.13\bin;C:\Users\niteris\dev\androidmonitor-client\FlutterSDK\gradle\gradle-8.2\bin;C:\Users\niteris\dev\androidmonitor-client\FlutterSDK\Android\sdk\build-tools\33.0.1;C:\Users\niteris\dev\androidmonitor-client\FlutterSDK\Android\sdk\cmdline-tools\latest\bin;C:\Users\niteris\dev\androidmonitor-client\FlutterSDK\Android\sdk\tools\bin;C:\Users\niteris\dev\androidmonitor-client\FlutterSDK\Android\sdk\emulator;C:\Users\niteris\dev\androidmonitor-client\FlutterSDK\Android\sdk\platform-tools;C:\Users\niteris\dev\androidmonitor-client\FlutterSDK\java\jdk-20.0.2\bin
SESSIONNAME=Console
PS1=\[\](venv) \[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ \[\]
NODE_PATH=C:\Users\niteris\AppData\Roaming\npm\node_modules
VSCODE_GIT_ASKPASS_MAIN=c:\Users\niteris\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\git\dist\askpass-main.js
CHROME_CRASHPAD_PIPE_NAME=\\.\pipe\crashpad_4728_VVAGTJXJLIGLBQIO
HOMEPATH=\Users\niteris
TMP=/tmp
PATH=c:\Users
iteris\.vscodetensions\ms-python.python-2024.8.1\python_files\deactivatash;C:\Users
iteris\dev\zcmds♂eninctivate;C;C:\Users
iteris\dev\zcmds♂env\Scripts;C:\Program Files\Git\mingw6in;C:\Program Files\Git\usin;C:\Users
iteriin;C:\Python310\Scripts;C:\Python310;C:\Users
iteris\AppData\Local\Programs\Python\Python311;C:\Users
iteris\AppData\Local\Programs\Python\Python311\Scripts;C:\Program Files (x86)\VMware\VMware Playein;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell♂1.0;C:\Windows\System32\OpenSSH;C:\Users
iteris\AppData\Roaming
pm;C:\ProgramData/mingw64/bin:/usr/bin:/c/Users/niteris/bin:/c/Users/niteris/.vscode/extensions/ms-python.python-2024.8.1/python_files/deactivate/bash:/c/Users/niteris/dev/zcmds/venv/bin/activate:C:/c/Users/niteris/dev/zcmds/venv/Scripts:/mingw64/bin:/usr/bin:/c/Users/niteris/bin:/c/Python310/Scripts:/c/Python310:/c/Users/niteris/AppData/Local/Programs/Python/Python311:/c/Users/niteris/AppData/Local/Programs/Python/Python311/Scripts:/c/Program Files (x86)/VMware/VMware Player/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/Users/niteris/AppData/Roaming/npm:/c/ProgramData/chocolatey/bin:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c/Program Files (x86)/Common Files/Acronis/VirtualFile:/c/Program Files (x86)/Common Files/Acronis/VirtualFile64:/c/Program Files (x86)/Common Files/Acronis/SnapAPI:/c/Program Files/Crucial/Crucial Storage Executive:/c/Program Files/OpenSSH/bin:/c/Program Files (x86)/Tailscale IPN:/c/Program Files/nodejs:/c/Program Files/NVIDIA Corporation/Nsight Compute 2022.3.0:/c/Program Files/dotnet:/c/Users/niteris/AppData/Local/Programs/Microsoft VS Code/bin:/c/tools/FlutterSDK/Android/cmdline-tools/latest/bin:/c/tools/gsudo/Current:/c/Program Files (x86)/Tesseract-OCR:/c/Program Files/PostgreSQL/15/bin:/c/Program Files/LLVM/bin:/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/c/Program Files/Amazon/AWSCLIV2:/c/tools/php82:/c/Program Files/Tailscale:/c/Program Files/Go/bin:/c/Program Files/PuTTY:/c/Program Files/RedHat/Podman:/c/Program Files/Docker/Docker/resources/bin:/c/Program Files/dotnet:/cmd:/c/Users/niteris/AppData/Local/Programs/Python/Python311/Scripts:/c/Users/niteris/AppData/Local/Programs/Python/Python311:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/flutter/bin:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/ant/apache-ant-1.10.13/bin:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/gradle/gradle-8.2/bin:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/Android/sdk/build-tools/33.0.1:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/Android/sdk/cmdline-tools/latest/bin:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/Android/sdk/tools/bin:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/Android/sdk/emulator:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/Android/sdk/platform-tools:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/java/jdk-20.0.2/bin:/c/Users/niteris/go/bin:/c/users/niteris/.local/bin:/c/Program Files/Chromium/Application:/c/tools/mysql/current/bin:/c/Users/niteris/.dotnet/tools:/c/Users/niteris/AppData/Local/Programs/Microsoft VS Code/bin:/c/Python310/Scripts:/c/Python310:/c/Users/niteris/AppData/Local/Programs/Python/Python311:/c/Users/niteris/AppData/Local/Programs/Python/Python311/Scripts:/c/Program Files (x86)/VMware/VMware Player/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/Users/niteris/AppData/Roaming/npm:/c/ProgramData/chocolatey/bin:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c/Program Files (x86)/Common Files/Acronis/VirtualFile:/c/Program Files (x86)/Common Files/Acronis/VirtualFile64:/c/Program Files (x86)/Common Files/Acronis/SnapAPI:/c/Program Files/Crucial/Crucial Storage Executive:/c/Program Files/OpenSSH/bin:/c/Program Files (x86)/Tailscale IPN:/c/Program Files/nodejs:/c/Program Files/NVIDIA Corporation/Nsight Compute 2022.3.0:/c/Program Files/dotnet:/c/Users/niteris/AppData/Local/Programs/Microsoft VS Code/bin:/c/tools/FlutterSDK/Android/cmdline-tools/latest/bin:/c/tools/gsudo/Current:/c/Program Files (x86)/Tesseract-OCR:/c/Program Files/PostgreSQL/15/bin:/c/Program Files/LLVM/bin:/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/c/Program Files/Amazon/AWSCLIV2:/c/tools/php82:/c/Program Files/Tailscale:/c/Program Files/Go/bin:/c/Program Files/PuTTY:/c/Program Files/RedHat/Podman:/c/Program Files/Docker/Docker/resources/bin:/c/Program Files/dotnet:/cmd:/c/Users/niteris/AppData/Local/Programs/Python/Python311/Scripts:/c/Users/niteris/AppData/Local/Programs/Python/Python311:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/flutter/bin:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/ant/apache-ant-1.10.13/bin:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/gradle/gradle-8.2/bin:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/Android/sdk/build-tools/33.0.1:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/Android/sdk/cmdline-tools/latest/bin:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/Android/sdk/tools/bin:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/Android/sdk/emulator:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/Android/sdk/platform-tools:/c/Users/niteris/dev/androidmonitor-client/FlutterSDK/java/jdk-20.0.2/bin:/c/Users/niteris/go/bin:/c/users/niteris/.local/bin:/c/Program Files/Chromium/Application:/c/tools/mysql/current/bin:/c/Users/niteris/.dotnet/tools:/c/Users/niteris/AppData/Local/Programs/Microsoft VS Code/bin
ProgramW6432=C:\Program Files
ORIGINAL_XDG_CURRENT_DESKTOP=undefined
WINDIR=C:\Windows
PROCESSOR_ARCHITECTURE=AMD64
PUBLIC=C:\Users\Public
MSYS=disable_pcon
SYSTEMDRIVE=C:
GOPATH=C:\Users\niteris\go
TERM_PROGRAM=vscode
ProgramData=C:\ProgramData
ChocolateyLastPathUpdate=133542520417535300
_=/usr/bin/env
(venv)

其中一个奇怪的事情是,在新更新中,HOME 环境变量被弄乱了。从环境变量中,我看到这个:

HOME=C:\Users
iteris

但是如果我使用 2024 年 3 月的版本,我看到这个:

HOME=/c/Users/niteris

所以我推测是设置不正确的 HOME 变量,插入了一个 \n 导致换行。这很有道理,因为如果将 / -> \,那么我的用户名是 \niteris,变成 \n + iteris,这就是你在命令行上看到的。
有趣的是,这似乎是来自注入的 VSCode 环境变量。如果我通过 cmd.exe 访问源代码仓库,然后启动 git-bash,然后调用 git,那么一切都可以正常工作。只有在通过 vscode 打开终端时才会出现问题。
这是我的 settings.json

{
    "python.autoComplete.extraPaths": [
        "."
    ],
    "terminal.integrated.defaultProfile.windows": "Git Bash",
    "terminal.integrated.profiles.windows": {
        "Git Bash": {
            "path": "C:\\Program Files\\Git\\bin\\bash.exe"
        },
        "cmd.exe": {
            "path": "C:\\Windows\\System32\\cmd.exe",
        }
    },
    // adds activate virtualenv to terminal
    "terminal.integrated.env.windows": {
        "VIRTUAL_ENV": "${workspaceFolder}/venv"
    },
    "files.eol": "\n", // Unix
    "editor.tabSize": 4,
    "editor.insertSpaces": true,
    "editor.detectIndentation": true,
    "python.analysis.extraPaths": [
        "."
    ]
}
2w3rbyxf

2w3rbyxf1#

我正在Windows(最新版本的VSCode)上遇到相同的问题:

lrpiutwd

lrpiutwd2#

@Tyriar,你有什么想法吗?谢谢!

piztneat

piztneat3#

不确定问题变更是什么,将进行调查。

ctrmrzij

ctrmrzij4#

关于这个有什么更新吗?

相关问题