Skip to content
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

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

Open
F-Loyer opened this issue Jan 23, 2024 · 10 comments
Open

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

F-Loyer opened this issue Jan 23, 2024 · 10 comments

Comments

@F-Loyer
Copy link

F-Loyer commented Jan 23, 2024

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
Copy link
Member

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

@F-Loyer
Copy link
Author

F-Loyer commented Jan 23, 2024

$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
Copy link
Member

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
Copy link
Author

F-Loyer commented Jan 23, 2024

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 ocaml-opam/opam-repository-mingw#15 on the repository project.

@kit-ty-kate
Copy link
Member

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
Copy link
Author

F-Loyer commented Jan 23, 2024

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
Copy link
Member

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 #5798 (comment) ? Did you remove your opam root by hand?

@F-Loyer
Copy link
Author

F-Loyer commented Jan 23, 2024

@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
Copy link
Member

@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
Copy link
Author

F-Loyer commented Jan 23, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants