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.25k stars 361 forks source link

opam doesn't find any compiler for a switch creation on Windows #5798

Open F-Loyer opened 10 months ago

F-Loyer commented 10 months ago

I have just installed opam-full-2.2.0-beta1 on Windows (make cold; make cold-install; opam init git+https://github.com/ocaml-opam/opam-repository-mingw).

But I can't create a switch:

$opam switch list-available
# Listing available compilers from repositories: default
# No matches found

opam update doesn't help (it quickly returns, no apparent download).

Also:

$opam config report
# opam config report
# opam-version         2.2.0~beta1
# 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
kit-ty-kate commented 9 months ago

Could you show us what’s the output of opam option and opam repo -a ?

F-Loyer commented 9 months ago
$opam option

<><> Global configuration <><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
archive-mirrors                {}
best-effort-prefix-criteria    {}
depext                         true
depext-bypass                  {}
depext-cannot-install          false
depext-run-installs            true
download-command               {}
download-jobs                  3
git-location                   {}
jobs                           {}
post-build-commands            {}
post-install-commands          {}
post-remove-commands           {}
post-session-commands          {}
pre-build-commands             {}
pre-install-commands           {}
pre-remove-commands            {}
pre-session-commands           {}
repository-validation-command  {}
solver                         {}
solver-criteria                {}
solver-fixup-criteria          {}
solver-upgrade-criteria        {}
swh-fallback                   true
sys-pkg-manager-cmd            ["cygwin" "C:\\Cygwin\\bin\\cygcheck.exe"]
wrap-build-commands            ["%{hooks}%/sandbox.sh" "build"] {os = "linux" | os = "macos"}
wrap-install-commands          ["%{hooks}%/sandbox.sh" "install"] {os = "linux" | os = "macos"}
wrap-remove-commands           ["%{hooks}%/sandbox.sh" "remove"] {os = "linux" | os = "macos"}

<><> Switch configuration <><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
No switch installed

and

$opam repo -a
# Repository # Url # Switches(rank)
kit-ty-kate commented 9 months ago

Ah, according to opam repo -a, https://github.com/ocaml-opam/opam-repository-mingw failed to be fetched. Have you seen an error message during the opam init step?

To try to reproduce it or fix it, could you try opam repo add default git+https://github.com/ocaml-opam/opam-repository-mingw ? (or if it fails because it’s saying that default already exist, try to replace add with set-url)

F-Loyer commented 9 months ago

With the opam repo set-url ... I have:

[ERROR] Opam has not been initialised, please run `opam init'

I try the opam init ... and find:

<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><>  🐫
[ERROR] Could not update repository "default": OpamDownload.Download_fail(_, "curl: code 404 while downloading
        https://github.com/ocaml-opam/opam-repository-mingw/index.tar.gz")
[ERROR] Initial download of repository failed.

I have submitted a ticket https://github.com/ocaml-opam/opam-repository-mingw/issues/15 on the repository project.

kit-ty-kate commented 9 months ago

you used opam init https://github.com/ocaml-opam/opam-repository-mingw instead of opam init git+https://github.com/ocaml-opam/opam-repository-mingw could you try again with that one?

F-Loyer commented 9 months ago

My bad, with git+, it works... nearly (fails to compile 4.14.1+msvc64c) !

...
# checking how to print strings... printf
# checking for x86_64-pc-windows-gcc... cl# checking whether the C compiler works... no
# configure: error: in `/cygdrive/c/Users/frede/AppData/Local/opam/default/.opam-switch/build/ocaml-variants.4.14.1+msvc64c':
# configure: error: C compiler cannot create executables
# See `config.log' for more details

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
β”Œβ”€ The following actions failed
β”‚ Ξ» build ocaml-variants 4.14.1+msvc64c
└─
β”Œβ”€ The following changes have been performed (the rest was aborted)
β”‚ βˆ— install base-bigarray base
β”‚ βˆ— install base-threads  base
β”‚ βˆ— install base-unix     base
└─

Note, I have both mingw and MSVC compilers installed.

However, opam switch create default 4.14.1+mingw64c has created my switch.

kit-ty-kate commented 9 months ago

awesome!

I’m still confused at how you ended up without any repositories despite giving the proper url in the first place (the original two first comments of this issue). Do you remember anything at all from the first time you called opam init git+https://github.com/ocaml-opam/opam-repository-mingw ? Do you have the logs somewhere by any chance?

Running opam init https://github.com/ocaml-opam/opam-repository-mingw (the wrong url) fails immediately and does not create the opam root, so it’s not that.

Also how did you end up from having an opam root to not having one in https://github.com/ocaml/opam/issues/5798#issuecomment-1906350254 ? Did you remove your opam root by hand?

F-Loyer commented 9 months ago

@kit-ty-kate I have tried with the git+prefix as proposed, and it has initialized an opam dir properly.

The issue with the msvc64c variant come from a PATH issue. (cl.exe) couldn’t be found.

kit-ty-kate commented 9 months ago

@kit-ty-kate I have tried with the git+prefix as proposed, and it has initialized an opam dir properly.

Yes, but I was asking about the first time around (the reason why you opened this issue), do you remember anything from then? An empty opam repo -a means there is no repositories in the current opam setup, despite opam init seemingly succeeding to create an opam root, which should be incompatible. Maybe you did hit Ctrl-C somewhere in the middle of the opam init ?

F-Loyer commented 9 months ago

Yes, it is possible that the first time I hit Ctrl-C since the actual compilation of ocaml in a switch takes a lot of time without printing anything. But I was sure to erase the opam directory.

Note: I have finally manage to build a msvc32c variant: from CMD : call "c:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" -arch=x86, then launch a Cygwin subshell, then create the switch. (-arch=amd64 is needed for a 64 bits switch). Launching a MSVC tool chain from cygwin is not straightforward!

I guess the ticket can be closed. Thanks for the help.