0

I am using git bash terminal in vscode for a git repository and the terminal unexpectedly shut off during a process. (I was installing packages from a requirements file and I am thinking my internet connection broke during that time.) Now whenever I open the terminal, it shows the following error: bash: warning: command substitution: ignored null byte in input.

Also, the default location at which git bash opens is not the repo root (C:/git/rep_root (main), which used to be the case earlier) but something like as follows: C:/.../AppData/Local/Programs/Microsoft VS Code (main)

If I open any other terminal like cmd or powershell, there are no annoying warnings and they still open at the repo root.

I am not sure what happened to cause the annoying warning and change the default location of git bash terminal.

What should I do to fix this? I am on git version 2.47.1.windows.2. I am suspecting it is something to do with git bash within vscode but I am not sure what to do.

EDIT 1: After running the following command PS4=':$BASH_SOURCE:$LINENO+' bash -xli, after the last successful return statement, here is the output:

::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:24+return 1
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:128+'[' -f 'C:/projectfolder/repo_root/.git/BISECT_LOG' ']'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:132+'[' -n '' ']'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:134+'[' -h 'C:/projectfolder/repo_root/.git/HEAD' ']'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:138+local head=
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:544+case "$ref_format" in
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:142+__git_eread 'C:/projectfolder/repo_root/.git/HEAD' head
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:2+test -r 'C:/projectfolder/repo_root/.git/HEAD'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:2+IFS='
'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:2+read -r head
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:550+case $head in
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:148+head=refs/heads/main
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:159+test -z refs/heads/main
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:178+b=refs/heads/main
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:183+'[' -n '' ']'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:187+local conflict=
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:188+'[' '' = yes ']'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:193+local w=
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:194+local i=
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:195+local s=
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:196+local u=
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:197+local h=
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:198+local c=
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:199+local p=
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:200+local upstream=
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:202+'[' true = false ']'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:208+'[' true = true ']'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:209+'[' -n '' ']'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:218+'[' -n '' ']'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:224+'[' -n '' ']'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:231+'[' -n '' ']'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:236+'[' -n '' ']'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:241+local 'z= '
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:243+b=main
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:244+'[' no = yes ']'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:249+'[' -n '' ']'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:253+local f=
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:254+local gitstring=main
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:256+'[' no = yes ']'
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:264+printf -- ' (%s)' main
::C:/Program Files/Git/mingw64/share/git/completion/git-prompt.sh:267+return 0

EDIT2: Interestingly, this warning seems to be intertwined with .venv created through ctrl+shift+P > Python:Create Environment in VScode. Any repo where a .venv is created, git bash terminal starts throwing this warning on startup and otherwise, git bash doesn't throw any warning. I am not sure if git bash executes something related to .venv on startup and not sure how to ascertain that.

22
  • 2
    What's in your bashrc file? It should be located at "${HOME}"/.bashrc. Startup errors are likely related to that or another startup configuration file. The warning means you're running something like $( command ) where the command is producing a null byte as part of its output. Commented Feb 4 at 17:53
  • 1
    @wjandrea - I checked in the C:/.../AppData/Local/Programs/Microsoft VS Code (main), there is no .git folder in this location. Commented Feb 4 at 20:34
  • 2
    I wouldn't be surprised if something were writing UTF-16 output since you're on Windows -- that's full of NULs when characters are in low-ASCII space. That said, we'd need to see the actual code being run when the error triggers to speak to exact cause -- which is to say, a minimal reproducible example. Commented Feb 4 at 21:19
  • 1
    @wjandrea - yes that is correct, there is no .git folder in C:/.../AppData/Local/Programs/Microsoft VS Code. Commented Feb 4 at 22:09
  • 2
    Any error message coming from bash immedately at the start, i.e. before you have to chance to enter anything, can be of one of two sources: One of the startup files which are automatically processed by any new bash process (see the section INVOCATION in the bash man page to find out which ones they are for your particular bash instance), or from a program which is invoked from your prompt (i.e. the variable PS1). Hence configure your terminal so that it executes bash with -x and have a look at where the error message exactly comes from. Commented Feb 5 at 9:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.