Paths exported from direnv are being converted to a Windows format when running in a terminal emulator on Windows. This breaks the terminal if the PATH is modified - any subsequent command in the terminal can not be found.
This was touched on here: #253 but I am not having the same issues - this is just a formatting issue with the paths.
Environment
- OS: Windows 10
- Shell: git bash / mintty
- Direnv version 2.28
$ cd "${target_dir}" # direnv not enabled yet.
direnv: error C:\Users\Chris\direnv-test\.envrc is blocked. Run `direnv allow` to approve its content
$ which direnv # No spaces in path to direnv executable
/c/Users/Chris/com.appalachia/appa/direnv
$ cat "${HOME}/.bashrc" # .bashrc correctly hooking direnv into bash.
eval "$(direnv hook bash)"
$ echo "${PATH}" # $PATH looks fine at this point.
/c/Users/Chris/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/Chris/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/Program Files/Microsoft SQL Server/120/Tools/Binn:/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Program Files/Git LFS:/cmd:/c/Users/Chris/com.appalachia/appa:/c/Program Files/nodejs:/c/ProgramData/chocolatey/bin:/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/c/Program Files/ImageMagick-7.0.11-Q16-HDRI:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c/Program Files/Common Files/Autodesk Shared:/c/Program Files (x86)/GitExtensions:/c/Users/Chris/com.appalachia/appa:/c/Users/Chris/AppData/Local/Programs/Python/Python39:/c/Users/Chris/AppData/Local/Programs/Microsoft VS Code/bin:/c/Users/Chris/AppData/Local/GitHubDesktop/bin:/c/Program Files/JetBrains/PyCharm Community Edition 2020.2.2/bin:/c/Users/Chris/AppData/Roaming/npm:/c/Program Files (x86)/GitHub CLI:/c/Users/Chris/AppData/Local/Microsoft/WindowsApps:/c/Users/Chris/AppData/Local/Programs/Python/Launcher:/c/Users/Chris/com.appalachia/node_modules/.bin:/c/Users/Chris/AppData/Local/Programs/Python/Python39/Scripts:/c/Users/Chris/.dotnet/tools:/usr/bin/vendor_perl:/usr/bin/core_perl
$ cat .envrc # .envrc file contents. $MODIFY_PATH flag will control if we either export a variable, or change the path.
if [ "${MODIFY_PATH}" == "1" ] ; then
echo ORIGINAL PATH && echo "------------------"
echo ${PATH} && echo "------------------"
PATH_add "${HOME}/temp"
echo MODIFIED PATH && echo "------------------"
echo ${PATH} && echo "------------------"
else
export TEMPVAR="${HOME}/temp"
echo "${TEMPVAR}"
fi
$ echo "${TEMPVAR-none}" && export MODIFY_PATH="0" # $TEMPVAR not set, preparing to execute the simple .envrc branch.
none
$ direnv allow # First run. Note the $TEMPVAR is in nix format when echoed.
direnv: loading ~/direnv-test/.envrc
/c/Users/Chris/temp
direnv: export +TEMPVAR
$ echo "${TEMPVAR-none}" && export MODIFY_PATH="1" # $TEMPVAR is now set, however path is in Windows format. Setting flag to execute the other .envrc branch.
C:/Users/Chris/temp
$ cd .. # Resetting for next direnv run.
direnv: unloading
$ cd "${target_dir}" # This will execute the $PATH modification branch.
direnv: loading ~/direnv-test/.envrc
ORIGINAL PATH
------------------
/c/Users/Chris/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/usr/bin:/mingw64/bin:/usr/bin:/c/Users/Chris/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/Program Files/Microsoft SQL Server/120/Tools/Binn:/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Program Files/Git LFS:/cmd:/c/Users/Chris/com.appalachia/appa:/c/Program Files/nodejs:/c/ProgramData/chocolatey/bin:/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/c/Program Files/ImageMagick-7.0.11-Q16-HDRI:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c/Program Files/Common Files/Autodesk Shared:/c/Program Files (x86)/GitExtensions:/c/Users/Chris/com.appalachia/appa:/c/Users/Chris/AppData/Local/Programs/Python/Python39:/c/Users/Chris/AppData/Local/Programs/Microsoft VS Code/bin:/c/Users/Chris/AppData/Local/GitHubDesktop/bin:/c/Program Files/JetBrains/PyCharm Community Edition 2020.2.2/bin:/c/Users/Chris/AppData/Roaming/npm:/c/Program Files (x86)/GitHub CLI:/c/Users/Chris/AppData/Local/Microsoft/WindowsApps:/c/Users/Chris/AppData/Local/Programs/Python/Launcher:/c/Users/Chris/com.appalachia/node_modules/.bin:/c/Users/Chris/AppData/Local/Programs/Python/Python39/Scripts:/c/Users/Chris/.dotnet/tools:/usr/bin/vendor_perl:/usr/bin/core_perl
------------------
MODIFIED PATH
------------------
/c/Users/Chris/temp:/c/Users/Chris/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/usr/bin:/mingw64/bin:/usr/bin:/c/Users/Chris/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/Program Files/Microsoft SQL Server/120/Tools/Binn:/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Program Files/Git LFS:/cmd:/c/Users/Chris/com.appalachia/appa:/c/Program Files/nodejs:/c/ProgramData/chocolatey/bin:/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/c/Program Files/ImageMagick-7.0.11-Q16-HDRI:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c/Program Files/Common Files/Autodesk Shared:/c/Program Files (x86)/GitExtensions:/c/Users/Chris/com.appalachia/appa:/c/Users/Chris/AppData/Local/Programs/Python/Python39:/c/Users/Chris/AppData/Local/Programs/Microsoft VS Code/bin:/c/Users/Chris/AppData/Local/GitHubDesktop/bin:/c/Program Files/JetBrains/PyCharm Community Edition 2020.2.2/bin:/c/Users/Chris/AppData/Roaming/npm:/c/Program Files (x86)/GitHub CLI:/c/Users/Chris/AppData/Local/Microsoft/WindowsApps:/c/Users/Chris/AppData/Local/Programs/Python/Launcher:/c/Users/Chris/com.appalachia/node_modules/.bin:/c/Users/Chris/AppData/Local/Programs/Python/Python39/Scripts:/c/Users/Chris/.dotnet/tools:/usr/bin/vendor_perl:/usr/bin/core_perl
------------------
direnv: export ~PATH
$ ls # Commands can not be found.
bash: ls: command not found
$ echo "${PATH}" # Path formats are no longer valid for this terminal.
C:\Users\Chris\temp;C:\Users\Chris\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Chris\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:\Program Files\Microsoft SQL Server\120\Tools\Binn;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Git LFS;C:\Program Files\Git\cmd;C:\Users\Chris\com.appalachia\appa;C:\Program Files\nodejs;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\ImageMagick-7.0.11-Q16-HDRI;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Common Files\Autodesk Shared;C:\Program Files (x86)\GitExtensions;C:\Users\Chris\com.appalachia\appa;C:\Users\Chris\AppData\Local\Programs\Python\Python39;C:\Users\Chris\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Chris\AppData\Local\GitHubDesktop\bin;C:\Program Files\JetBrains\PyCharm Community Edition 2020.2.2\bin;C:\Users\Chris\AppData\Roaming\npm;C:\Program Files (x86)\GitHub CLI;C:\Users\Chris\AppData\Local\Microsoft\WindowsApps;C:\Users\Chris\AppData\Local\Programs\Python\Launcher;C:\Users\Chris\com.appalachia\node_modules\.bin;C:\Users\Chris\AppData\Local\Programs\Python\Python39\Scripts;C:\Users\Chris\.dotnet\tools;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
Paths exported from direnv are being converted to a Windows format when running in a terminal emulator on Windows. This breaks the terminal if the PATH is modified - any subsequent command in the terminal can not be found.
This was touched on here: #253 but I am not having the same issues - this is just a formatting issue with the paths.
Environment
$ which direnv # No spaces in path to direnv executable /c/Users/Chris/com.appalachia/appa/direnv