-
Notifications
You must be signed in to change notification settings - Fork 372
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
Cygpath the PATH from opam env #4844
Cygpath the PATH from opam env #4844
Conversation
dbe720f
to
19a7daa
Compare
19a7daa
to
f202567
Compare
Rebased. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit uneasy about this one, to be honest - mostly, I think if you want to use a Cygwin or MSYS2 shell, then it's better to use a Cygwin or MSYS2 opam
, but our cross-compilation and tooling story isn't good enough for me to insist on that yet!
A thought for the \r
issue - I expect this can be fixed by detecting that stdout is not a tty (i.e. you're inside $(eval )
) and detecting the parent as being a Cygwin-ish shell (it's in the same class of shim that the OCaml toplevel uses to display colour in mintty, etc.). That depends on your other PR and also on a further bit of work on top of that which I've done which gives the full path to the parent process, so perhaps it would be worth opening an issue to track that.
This can be merged once the "--"
part is added, thanks!
Co-authored-by: David Allsopp <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to merge when CI finishes, thanks!
CI is green. Thanks! |
When using a native Windows opam.exe the PATH from
opam env
is in Windows format.PowerShell output from
opam env
:$env:PATH = 'Z:\source\opam\_opam\bin;...'
CMD.exe output from
opam env
:SET PATH=Z:\source\opam\_opam\bin;...
With this change both MSYS2 and Cygwin will Unix-ize the PATH with essentially
cygpath --path $PATH
.Cygwin output from
opam env
:PATH='/cygdrive/c/Users/beckf/AppData/Local/opam/diskuv-boot-DO-NOT-DELETE/bin:...'
MSYS2 output from
opam env
:PATH='/z/source/opam/_opam/bin:...'
cygpath --path
on an already Unix PATH is idempotent, so a Cygwin opam.exe will still work after this change. That is, the following says "MATCHES" on both Cygwin and MSYS2:This PR gets
eval $(opam env)
working from a native Windows opam.exe into a MSYS2 shell. However the same command in a Cygwin shell chokes with-bash: $'\r': command not found
because native Windows opam.exe prints carriage returns (which MSYS2 eval can handle, but not Cygwin). I don't actually know a clean fix for that, and I suspect removing carriage returns when in MSYS2/Cygwin probably belongs in another PR.