ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.23k stars 351 forks source link

After having installed opam with msys, the command opam init fails #5713

Open Chimrod opened 10 months ago

Chimrod commented 10 months ago

I’ve upgraded opam to the latest version git version. The compilation process now works fine, but I have an error when creating a new fresh environnent.

2023-10-31_11h10_24

$ opam config report
# opam config report
# opam-version         2.2.0~alpha3~dev (c4961baf23e681c74b381a5f9c2cfd7362740e68)
# self-upgrade         no
# system               arch=x86_64 os=win32 os-distribution=cygwin os-version=10.0.22621
# solver               builtin-mccs+glpk
# install-criteria     -removed,-count[avoid-version,changed],-count[version-lag,request],-count[version-lag,changed],-count[missing-depexts,changed],-changed
# upgrade-criteria     -removed,-count[avoid-version,changed],-count[version-lag,solution],-count[missing-depexts,changed],-new
# jobs                 7
# current-switch       none set

I’ve extracted the log and the environment files generated by opam:

ocaml-base-compiler-25444-20665a.env.txt ocaml-base-compiler-25444-20665a.out.txt

kit-ty-kate commented 10 months ago

Note that opam does not officially support running with a MSYS2 environment at the moment, we only officially support Cygwin. We currently do not have the knowledge or time necessary to support and test both. Hopefully in the future but not now. That said, with sufficiant knowledge of MSYS2 it should work in theory, if i remember correctly.

A quick look at a search engine with the error you got, gives me https://github.com/msys2/MSYS2-packages/issues/1794, which looks like it states that mixing mingw libraries and msys2 system libraries can lead to this kind of error. Your PATH contains both the mingw path and the msys2 system (as well as a cygwin path?). Maybe it would work if you removed D:\msys64\mingw64\bin; from your PATH.

cc @jonahbeckford in case you’re interested.

jonahbeckford commented 10 months ago

Yes, the latest versions of opam install Cygwin during its opam initialization; that uses a DLL cygwin1.dll that cannot be active at the same time as MSYS2 (msys-2.0.dll). Even though there was no official support for MSYS2, MSYS2 did work quite well. You may be better off using an older version of opam (ie. commits around 2022/12/21).

And if you are just looking for prebuilt native Windows binaries (compatible with MSYS2), grab v2.2.0-alpha-20221228 from https://github.com/diskuv/dkml-component-opam/releases.

kit-ty-kate commented 10 months ago

Even though there was no official support for MSYS2, MSYS2 did work quite well. You may be better off using an older version of opam (ie. commits around 2022/12/21).

Do you know what broke it? Is it the thing you explained in https://github.com/ocaml/opam/issues/5683 or is there something else?

Chimrod commented 10 months ago

Hello, thanks all for your answer. I completely understand that the situation here is very specific, but I didn’t know if it was out of the scope or not. As I know you are still stabilizing the windows version, I’ve estimated this issue could be reported here.

jonahbeckford commented 10 months ago

Yes, it is the thing in #5683 (which is being worked on).

kit-ty-kate commented 10 months ago

@Chimrod how did you use opam init ? Could you try https://github.com/ocaml/opam/issues/5683#issuecomment-1794831405

Chimrod commented 10 months ago

(Oh, I’ve answer in the wrong ticket. Sorry for the noise.)

When I specify the path to msys (in my case D:\msys64), opam look for a subdirectory \home\msys64 which do not exists:

$ opam init  --cygwin-location=D:\msys64
[WARNING] Flag --cygwin-location is experimental, there is no guarantee that it will be kept; avoid using it in
          scripts.
No configuration file found, using built-in defaults.

<><> Unix support infrastructure ><><><><><><><><><><><><><><><><><><><><><>  🐫
[ERROR] Error while checking Cygwin install (C:\cygwin64): D:\msys64\home\msys64 not found!

I’ve tried differents way to spectify the path, but I do not understand the hierarchy required

rjbou commented 9 months ago

Which term are you using ? i'm testing it with cmd (make cold on cygwin), and there is no path rewriting. It is not working because it detects that it is not an cygwin install, but looks for in the given path. The good path to give is the one that contains bin directory.