Skip to content

Bug: docker build failure, bogus pinned package versions, "Toplevel not initialized" #621

@tsani

Description

@tsani

Related user(s):

No response

Related issue(s) or PR(s):

No response

Related project scope(s):

No response

Bug description:

On a fresh clone of learn-ocaml, docker build -t learn-ocaml . fails.

% docker build -t learn-ocaml-upstream-fresh .                                          !1236
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            Install the buildx component to build images with BuildKit:
            https://docs.docker.com/go/buildx/

Sending build context to Docker daemon  7.961MB
Step 1/50 : FROM ocaml/opam:alpine-3.20-ocaml-5.1 as compilation
 ---> 769eba67977b
Step 2/50 : LABEL Description="learn-ocaml building" Vendor="OCamlPro"
 ---> Using cache
 ---> 6aaf4ca5fbb2
Step 3/50 : WORKDIR /home/opam/learn-ocaml
 ---> Using cache
 ---> e53756a14ee3
Step 4/50 : COPY learn-ocaml.opam learn-ocaml.opam.locked learn-ocaml-client.opam learn-ocaml-client.opam.locked ./
 ---> Using cache
 ---> 07b98c3e319a
Step 5/50 : RUN sudo chown -R opam:nogroup .
 ---> Using cache
 ---> 49071d72f9a1
Step 6/50 : ENV OPAMYES true
 ---> Using cache
 ---> b607c919d9bf
Step 7/50 : RUN echo 'archive-mirrors: [ "https://opam.ocaml.org/cache" ]' >> ~/.opam/config   && opam repository set-url default http://opam.ocaml.org   && opam switch 5.1   && echo 'pre-session-commands: [ "sudo" "apk" "add" depexts ]' >> ~/.opam/config   && opam install . --deps-only --locked
 ---> Running in 73c5bde75327
[default] Initialised
default (at http://opam.ocaml.org): 
    [INFO] opam 2.1 and 2.2 include many performance and security improvements over 2.0; please consider upgrading (https://opam.ocaml.org/doc/Install.html)

# Run eval $(opam env) to update the current shell environment
The following dependencies couldn't be met:
  - learn-ocaml-client -> cmdliner = 1.1.0
      no matching version

No solution found, exiting
The command '/bin/sh -c echo 'archive-mirrors: [ "https://opam.ocaml.org/cache" ]' >> ~/.opam/config   && opam repository set-url default http://opam.ocaml.org   && opam switch 5.1   && echo 'pre-session-commands: [ "sudo" "apk" "add" depexts ]' >> ~/.opam/config   && opam install . --deps-only --locked' returned a non-zero code: 20

Indeed, cmdliner version 1.1.0 does not exist on opam. The available versions are 1.0.4 and 1.3.0. The changelog of cmdliner shows that version 1.2.0 did exist. I don't understand why it isn't on opam anymore. The same situation holds for several other packages, e.g. learnocaml wants version 1.2.0 of digestif, but that version is not available on opam.

In an attempt to get learn-ocaml to build, I tried to generate new lockfiles like this, pinning to versions that can actually be found in opam.

% rm *.locked
% opam switch create 5.1.1
% eval "$(opam env --set-switch --switch=5.1.1)"
% opam install --deps-only .
% opam lock learn-ocaml
% opam lock learn-ocaml-client

This works, and opam is able to find a solution that satisfies the minimum bounds set out in the .opam files of learn-ocaml and learn-ocaml-client.

Moreover, the build succeeds with dune build and with docker build -t learn-ocaml . using these lockfiles instead of the checked-in ones.

The learn-ocaml server is able to start, and I'm able to navigate to http://localhost:8080. Pages load just fine.

However, anything that tries to execute OCaml code fails. For instance, visiting the toplevel activity shows an error

File "_none_", line 1:
Error: Toplevel not initialized
(jsoo_toplevel_compile)
Image

Loading the demo exercise from the demo repository fails with a modal popup error "Internal error: error in prelude" but the prelude is simply

(* Some code is loaded in the toplevel before your code. *)
let greetings = "Hello world!"

so I figure that the displayed modal error is actually masking the fact that the toplevel has failed to initialize.

Anyway, I reckoned that these issues with the toplevel arise from having changed many package versions, including a minor version of js_of_ocaml packages, going from 5.8.2 to 5.9.1.

This hunch was correct. Manually adjusting the lockfiles to use version 5.8.2 of js_of_ocaml solves this error, and learn-ocaml is able to build and run correctly.

I'll momentarily open a PR with the adjusted lockfiles.

To reproduce:

No response

Expected behavior:

No response

learn-ocaml --version

No response

git describe --long --always --abbrev=40 --tags

No response

What OS do you use?

GNU/Linux

What OS version/distribution do you use?

arch linux

What browser(s) do you use with learn-ocaml?

No response

What browser(s) version did you used to reproduce the issue?

No response

Screenshots (if need be):

No response

Additional context:

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions