-
Notifications
You must be signed in to change notification settings - Fork 626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PATH gets mangled when using direnv from git-bash on Windows #253
Comments
Hi, thanks for the comprehensive report. It's a long shot but can you try the latest release? It's now built with go 1.8 which has improved the windows path support. I produce the windows binaries because it's easy to do so with Go but I must admit of not having tested it. |
Nope, no luck. Knowing that it's not really tested/supported on Windows helps though; if I get a chance I'll try to dig in a bit more and figure out whether it's something that can be worked around. Thanks! |
Cool. I'm very interested in having good Windows support, it's just that I am not using it day-to-day. Maybe also have a look at the existing windows issues, it might give you some more clues: https://github.com/direnv/direnv/issues?q=is%3Aopen+is%3Aissue+label%3AWindows |
@irontoby, I am experiencing the same issue and would be glad to help as well. If I can do any testing or coding (I've no production experience writing golang, but love to tinker with it). |
Can you try to run Basically I think we would have to replace or expand the |
That's another issue we'll hit with Windows. Because there is a white space in the $PWD, bash interprets it as multiple arguments. Make sure to put double quotes around $PWD, or any variables in general. |
It's possible some of the stdlib.sh isn't escaped properly. Can you simplify the |
I'm about to go down this path. Any movement on this? |
Nope, sorry. |
The function would fail if direnv lived in a path which contains whitespaces (aka Windows C:\\Program Files) See #253
@markwest1 @xn can you try the current master? I think I fixed this particular issue. |
I get a similar error when using direnv 2.11.3. Tried both 64-bit and 32-bit direnv, with a Git Bash context. If I use a blank .envrc, or a .envrc with 100% commented out code, my Git Bash shell works fine. If I try to source rsvm from .envrc, then the resulting Git Bash shell environment can no longer execute commands. One way to help alleviate this, is for direnv to determine whether it is running in a cygwin/unix/linux/mingw/msys/Git Bash/Windows Subsystem for Linux context vs. a native Windows/Command Prompt/PowerShell context. If There are plenty of other ways to distinguish environments, but A detection scheme like that would go a long way toward resolving compatibility issues for direnv across Unix, Windows, and cygwin environments. |
@mcandre I agree, right now direnv is relying on the golang stdlib path package but I think that it's not sufficient for windows support as windows is not a single target. If someone is willing to implement a path package that works in all these environments it would go a long way to have direnv supported on windows. Right now I suspect that direnv will only work properly inside of the WSL. |
BTW, I got it working. |
in git-bash
|
was the solution to remove whitespaces from the path? |
yes |
@zimbatm the issue is resolved when using |
no worries. if you still have whitespaces try direnv v2.12.2, it should also fix the issue |
I'm still having issues with the current version of direnv in Windows Git Bash. For my use case I want to extend the PATH variable, which also contains spaces. As a crude workaround I patched the prompt hook. So instead of calling
This hook feeds PATH assignments through Also, since direnv is a non-MSYS executable, MSYS will translate other environment variables (according to these rules) before calling it. This was undesirable for my scenario so I disable it by setting Edit: |
Additionally in the latest version, even an empty .envrc on win10 with gitbash triggers this error:
|
Here's a similar hack, replacing export _unmangle_direnv_names='PATH'
_unmangle_direnv_paths() {
for k in $_unmangle_direnv_names; do
eval "$k=\"\$(/usr/bin/cygpath -p \"\$$k\")\""
done
}
eval "$(direnv hook bash | sed -e 's@export bash)@export bash)\
_unmangle_direnv_paths@')" If path-unmangling is required for other variables, they can be added to |
Your _direnv_hook was very helpful, Thanks for sharing!
I just tested |
Hello,
Installing the official
git
release for Windows will also install thegit-bash.exe
shell. Rather than an emulation layer, I believe this isbash
plus lots of the standard Linux tools which have been compiled directly for Windows (it seems to be based off the Mingw-w64 project).Within this shell, it mounts the Windows
C:
drive as/c
and converts all the Windows paths to their Bash equivalents. For example myPATH
right now looks something like this:I downloaded the Windows version of
direnv
(direnv.windows-amd64.exe) and put it in a folder in my path. Then I addedeval "$(direnv hook bash)"
to my.bashrc
. However when I create an.envrc
and try eitherPATH_add node_modules/.bin
orexport PATH=$PWD/node_modules/.bin:$PATH
, it appears that direnv is converting my$PATH
to use Windows-style paths instead:Is there a way to get the Windows .exe to use Bash-style paths and not try to convert them? Or is there a config setting I need to change to get this behavior?
The text was updated successfully, but these errors were encountered: