ocaml-sf / learn-ocaml

A Web Application for Learning OCaml
https://ocaml-sf.org/learn-ocaml/
MIT License
303 stars 66 forks source link

Bug: the switch doesn't compile #463

Open readyready15728 opened 2 years ago

readyready15728 commented 2 years ago

Bug description

Pretty self-explanatory, doesn't compile because of a slightly wrong OCaml version.

To reproduce

Steps to reproduce the behavior:

  1. git clone the repo.
  2. Attempt to start the build process with opam switch create . --deps-only --locked.
  3. Wait for a bit.

Expected behavior

For the switch to compile.

Optional screenshots

I'd prefer to give you text which is probably easier to work with and will do so below.

Current configuration

Additional context

Here is probably the "meat":

[ERROR] The compilation of ocaml.4.12.1 failed at "ocaml /home/readyready15728/src/learn-ocaml/_opam/share/ocaml-config/gen_ocaml_config.ml
        4.12.1 ocaml".

#=== ERROR while compiling ocaml.4.12.1 =======================================#
# context     2.1.0 | linux/x86_64 |  | https://opam.ocaml.org#1fc79772
# path        ~/src/learn-ocaml/_opam/.opam-switch/build/ocaml.4.12.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build ocaml /home/readyready15728/src/learn-ocaml/_opam/share/ocaml-config/gen_ocaml_config.ml 4.12.1 ocaml
# exit-code   1
# env-file    ~/.opam/log/ocaml-38639-e3db12.env
# output-file ~/.opam/log/ocaml-38639-e3db12.out
### output ###
# OCaml version mismatch: 4.12.2, expected 4.12.1

There's a little afterwards which I'll include as well:

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build ocaml 4.12.1
└─
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install base-bigarray         base
│ ∗ install base-threads          base
│ ∗ install base-unix             base
│ ∗ install conf-git              1.0
│ ∗ install conf-libssl           3
│ ∗ install conf-pkg-config       2
│ ∗ install conf-which            1
│ ∗ install ocaml-config          2
│ ∗ install ocaml-options-vanilla 1
│ ∗ install ocaml-variants        4.12.1+trunk
└─
# Run eval (opam env) to update the current shell environment
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] Y

I noticed there are logs too although the .out file doesn't tell me anything that you haven't already seen re: the version mismatch. I'll give you the .env stuff though:

CAML_LD_LIBRARY_PATH=/home/readyready15728/src/learn-ocaml/_opam/lib/stublibs
CDPATH=
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
HOME=/home/readyready15728
LANG=C.UTF-8
LC_ALL=en_US.UTF-8
LOGNAME=readyready15728
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
MAKEFLAGS=
MAKELEVEL=
MANPATH=:/home/readyready15728/src/learn-ocaml/_opam/man
MOTD_SHOWN=pam
OCAML_TOPLEVEL_PATH=
OMF_CONFIG=/home/readyready15728/.config/omf
OMF_PATH=/home/readyready15728/.local/share/omf
OPAMCLI=2.0
OPAMROOT=/home/readyready15728/.opam
OPAMSWITCH=/home/readyready15728/src/learn-ocaml
OPAM_PACKAGE_NAME=ocaml
OPAM_PACKAGE_VERSION=4.12.1
OPAM_SWITCH_PREFIX=/home/readyready15728/src/learn-ocaml/_opam
PATH=/home/readyready15728/src/learn-ocaml/_opam/bin:/opt/rakudo-pkg/var/zef/bin:/opt/rakudo-pkg/bin:/opt/rakudo-pkg/share/perl6/bin:/home/readyready15728/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PWD=/home/readyready15728/src/learn-ocaml
RAKULIB=/opt/rakudo-pkg/var/zef/lib
SHELL=/usr/bin/fish
SHLVL=1
SSH_CLIENT=70.15.161.208 44598 22
SSH_CONNECTION=70.15.161.208 44598 67.205.147.177 22
SSH_TTY=/dev/pts/0
TERM=xterm-256color
USER=readyready15728
XDG_RUNTIME_DIR=/run/user/1000
XDG_SESSION_CLASS=user
XDG_SESSION_ID=46
XDG_SESSION_TYPE=tty

eval (opam env) sans dollar sign is correct because I'm using fish FWIW. I wish I could offer more detail including steps towards the fix but I'm obviously just a learner. I attempted monkeying around with some of the opam configuration files attempting to force the slightly newer OCaml version rather than what appears to specifying "any 4.12 version" but that ended up going nowhere. Sorry about that.

readyready15728 commented 2 years ago

ADDENDUM: I tried forcing 4.12.1 too in the two .opam files then tossing out the .locked files before another attempt at compiling the switch. No dice. I tried 4.12.2 once again and here's what happened:

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["ocaml" {>= "4.05.0"}]
[ERROR] Could not determine which packages to install for this switch:
  * Missing dependency:
    - ocaml = 4.12.2
    no matching version

Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] Y

ADDENDUM 2: I'm trying the previously described attempted fix with "ocaml" {>= "4.12"} and it has succeeded. Not sure if that is what is desired though.

erikmd commented 2 years ago

Hi @readyready15728, sorry for late reply, and thanks a lot for your thourough bug report!

My understanding is that:

indeed, see this line:

https://github.com/ocaml-sf/learn-ocaml/blob/6e3fa0f8731a383f70006abf127bbf3c8a6218ee/learn-ocaml.opam#L43

cf. the line you had spotted:

https://github.com/ocaml-sf/learn-ocaml/blob/6e3fa0f8731a383f70006abf127bbf3c8a6218ee/learn-ocaml-client.opam.locked#L70

As a result:

readyready15728 commented 2 years ago

As of now, I have no idea about any of that my good dude. I'm just someone working through the CS3110 course from Cornell. Just glad I unearthed the error and made a little progress towards solving it.

AltGr commented 2 years ago

This is an opam error, not a learn-ocaml issue. The ocaml package is only a virtual package depending on one of ocaml-base-compiler, ocaml-system, etc. ; here it seems you have ocaml-variants.4.12.1+trunk getting installed which is wrong, you want ocaml-base-compiler. Please check your opam version, run opam update to make sure package definitions are up-to-date, try again and report to ocaml/opam-repository if the issue persists.