opam icon indicating copy to clipboard operation
opam copied to clipboard

Incorrect message on windows for updating environment vars

Open JonasOberhauser opened this issue 1 year ago • 7 comments

On windows, I get a message to run eval $(opam env). E.g.:



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build coq-core 8.19.2
+-
- No changes have been performed
# Run eval $(opam env) to update the current shell environment

If I do, my $PATH is totally messed up and opam is no longer in the path.

Instead, it seems I should be using the command provided in a blog post here:

https://opam.ocaml.org/blog/opam-2-2-0-windows/

On second inspection, It seems that this only happens in my mingw shell, in powershell I get the correct command. But either way running eval $(opam env) in the mingw shell does not produce the correct results.

JonasOberhauser avatar Jul 31 '24 16:07 JonasOberhauser

Can you share the output of opam env in your mingw shell?

rjbou avatar Aug 02 '24 16:08 rjbou

Indeed, if you're running opam from within Cygwin/MSYS2, etc. (i.e. bash or some such) then the command suggested is correct and it is supposed to work!

dra27 avatar Aug 05 '24 08:08 dra27

Can you share the output of opam env in your mingw shell?

I can tell you how the output differs from what is there in a working environment: all the paths (including paths unrelated to ocaml) are prefixed with /cygdrive/c/... or /cygdrive/d/..., e.g.,

...:/cygdrive/d/Program Files/Git/usr/bin/core_perl

while my working PATH has it as ...:/usr/bin/core_perl

JonasOberhauser avatar Aug 07 '24 17:08 JonasOberhauser

I can tell you how the output differs from what is there in a working environment: all the paths (including paths unrelated to ocaml) are prefixed with /cygdrive/c/... or /cygdrive/d/...

both should be equivalent in a cygwin context so i'm not sure why that would break things. Are you using MSYS2, an existing Cygwin installation or the recommended internal Cygwin installation?

...:/cygdrive/d/Program Files/Git/usr/bin/core_perl

while my working PATH has it as ...:/usr/bin/core_perl

This part is pretty surprising though, are you sure this is verbatim what's in your PATH? If so, opam is introducing the Git for Windows path without a separator (it should at least be ...:/cygdrive/d/Program Files/Git:/usr/bin/core_perl)

kit-ty-kate avatar Aug 07 '24 18:08 kit-ty-kate

I’ve just noticed something similar to this running opam-with-an-internal-Cygwin installation running in a different Cygwin installation - looks like you’re running opam-with-an-internal-Cygwin-installation in Git for Windows Bash (or an MSYS2 installation) and seeing a bigger version of the same problem.

dra27 avatar Aug 08 '24 07:08 dra27

(I also have an idea for a fix…)

dra27 avatar Aug 08 '24 07:08 dra27

I can tell you how the output differs from what is there in a working environment: all the paths (including paths unrelated to ocaml) are prefixed with /cygdrive/c/... or /cygdrive/d/...

both should be equivalent in a cygwin context so i'm not sure why that would break things. Are you using MSYS2, an existing Cygwin installation or the recommended internal Cygwin installation?

I am using my git for windows bash.

...:/cygdrive/d/Program Files/Git/usr/bin/core_perl while my working PATH has it as ...:/usr/bin/core_perl

This part is pretty surprising though, are you sure this is verbatim what's in your PATH? If so, opam is introducing the Git for Windows path without a separator (it should at least be ...:/cygdrive/d/Program Files/Git:/usr/bin/core_perl)

Yep image

JonasOberhauser avatar Aug 08 '24 14:08 JonasOberhauser