Search code examples
bashterminalpathgit-bashmingw-w64

"bash: export: ... not a valid identifier" in CLI of git-bash shell "MINGW64" on Windows 10


Using git for Windows, I always get the following output when opening a new git-bash terminal:

bash: export: `C:\Users\username\Projects\proj1\src\packages\;C:\Users\username\Projects\proj2\MachineLearning\;C:\Users\username\Projects\proj2\MachineLearning\azure_components\': not a valid identifier

Next, I examined the PATH variable via echo $PATH:

C:\Users\username\Projects\proj1-venv/Scripts:/c/Users/username/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/username/bin:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Program Files/dotnet:/c/ProgramData/chocolatey/bin:/cmd:/c/users/username/.pyenv/pyenv-win/versions/3.9.0a4/Scripts:/c/Program Files/PuTTY:/c/Program Files/Amazon/AWSCLIV2:/c/ProgramData/chocolatey/lib/gsudo/bin:/c/Program Files/Amazon/AWSSAMCLI/bin:/c/Users/username/AppData/Local/Terraform:/c/Users/username/AppData/Local/iPython:/c/Program Files/Docker/Docker/resources/bin:/c/ProgramData/DockerDesktop/version-bin:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/150/DTS/Binn:/c/Program Files/Azure Data Studio/bin:/c/Users/username/.pyenv/pyenv-win/bin:/c/Users/username/.pyenv/pyenv-win/shims:/c/Users/username/.pyenv/pyenv-win/bin:/c/Users/username/.pyenv/pyenv-win/shims:/c/Users/username/AppData/Local/Microsoft/WindowsApps:/c/Users/username/AppData/Local/Programs/Microsoft_VS_Code/bin:/c/Users/username/.pyenv/pyenv-win/bin:/c/Users/username/.pyenv/pyenv-win/shims:/c/Users/username/AppData/Local/Pandoc:/c/texlive/2021/bin/win32:/c/Users/username/AppData/Local/Terraform:/c/Users/username/AppData/Local/iPython:/c/Users/username/.dotnet/tools:/c/Program Files/Azure Data Studio/bin:/usr/bin/vendor_perl:/usr/bin/core_perl

I tried to export the content of $PATH explicitely using export $PATH which throws the same error bash: export: ... not a valid identifier many times over:

bash: export: `C:\Users\username\Projects\proj1-venv/Scripts:/c/Users/username/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/username/bin:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Program': not a valid identifier
bash: export: `Files/dotnet:/c/ProgramData/chocolatey/bin:/cmd:/c/users/username/.pyenv/pyenv-win/versions/3.9.0a4/Scripts:/c/Program': not a valid identifier
bash: export: `Files/PuTTY:/c/Program': not a valid identifier
bash: export: `Files/Amazon/AWSCLIV2:/c/ProgramData/chocolatey/lib/gsudo/bin:/c/Program': not a valid identifier
bash: export: `Files/Amazon/AWSSAMCLI/bin:/c/Users/username/AppData/Local/Terraform:/c/Users/username/AppData/Local/iPython:/c/Program': not a valid identifier
bash: export: `Files/Docker/Docker/resources/bin:/c/ProgramData/DockerDesktop/version-bin:/c/Program': not a valid identifier
bash: export: `Files/Microsoft': not a valid identifier
bash: export: `Server/130/Tools/Binn:/c/Program': not a valid identifier
bash: export: `Files/Microsoft': not a valid identifier
bash: export: `Server/Client': not a valid identifier
bash: export: `SDK/ODBC/170/Tools/Binn:/c/Program': not a valid identifier
bash: export: `(x86)/Microsoft': not a valid identifier
bash: export: `Server/150/DTS/Binn:/c/Program': not a valid identifier
bash: export: `Files/Azure': not a valid identifier
bash: export: `Studio/bin:/c/Users/username/.pyenv/pyenv-win/bin:/c/Users/username/.pyenv/pyenv-win/shims:/c/Users/username/.pyenv/pyenv-win/bin:/c/Users/username/.pyenv/pyenv-win/shims:/c/Users/username/AppData/Local/Microsoft/WindowsApps:/c/Users/username/AppData/Local/Programs/Microsoft_VS_Code/bin:/c/Users/username/.pyenv/pyenv-win/bin:/c/Users/username/.pyenv/pyenv-win/shims:/c/Users/username/AppData/Local/Pandoc:/c/texlive/2021/bin/win32:/c/Users/username/AppData/Local/Terraform:/c/Users/username/AppData/Local/iPython:/c/Users/username/.dotnet/tools:/c/Program': not a valid identifier
bash: export: `Files/Azure': not a valid identifier
bash: export: `Studio/bin:/usr/bin/vendor_perl:/usr/bin/core_perl': not a valid identifier

I suspect that it is related to the space characters in many of the paths, which is quite common on Windows, but not liked by UNIX-systems.

Assuming this is the culprit, how would I best get around this issue? If something else is responsible for this undesired behavior, I would also like to understand that.


Solution

  • As correctly pointed out in the first comment under my OP by @Zilog80, I had to check and remove all $ after the export-command in the following bash start-up scripts:

    1. .bashrc
    2. .bash_profile
    3. .profile

    In my case, all the fuss boiled down to the following line in my ~/.bashrc - script:

    export $PYTHONPATH
    

    This had to be replaced with

    export PYTHONPATH
    

    Now, opening a new terminal-session does not throw these "bash: export: … not a valid identifier" - errors anymore.