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

Minor dream-mirage fixes #283

Merged
merged 6 commits into from
Nov 2, 2023
Merged

Minor dream-mirage fixes #283

merged 6 commits into from
Nov 2, 2023

Conversation

tmcgilchrist
Copy link
Contributor

The doc changes try to mirror the organisation in dream.mli as closely a possible.
As a follow up PR I can re-organise dream-mirage to exactly mirror the main dream docs.
It would be helpful for them to be in sync and it makes it easier to see what has changed when diffing dream and dream-mirage. What do you think @aantron ?

Earlier versions of lwt_ppx used in dream-mirage can conflict with the base ocaml version 4.08 required by dream.opam.

For example:
Fatal error: exception File "src/mirage/mirage.ml", line 389, characters 2-34: complex open are not supported before OCaml 4.08
@tmcgilchrist
Copy link
Contributor Author

For fcc20d0 I get the following error when installing the minimum bounds for dream and dream-mirage. Which I understood to mean lwt_ppx is using an older version of the ocaml parse tree that doesn't support complex opens. They were added in 4.08 with Generalized open statements.

# File "src/mirage/dune", line 20, characters 13-26:
# 20 |  (preprocess (pps lwt_ppx))
#                   ^^^^^^^^^^^^^
# (cd _build/default && .ppx/bcab0be011c28261c514e69f4fe141f8/ppx.exe --cookie 'library-name="dream__mirage"' -o src/mirage/mirage.pp.ml --impl src/mirage/mirage.ml --dump-ast)
# Fatal error: exception File "src/mirage/mirage.ml", line 389, characters 2-34: complex open are not supported before OCaml 4.08

@aantron
Copy link
Owner

aantron commented May 17, 2023

I'm currently unable to test this because of

λ eval (opam env --switch=dream-mirage-4.14.1 --set-switch)
λ opam repo list                                                                                                                                                        2

[NOTE] These are the repositories in use by the current switch. Use '--all' to see all configured repositories.

<><> Repository configuration for switch dream-mirage-4.14.1 ><><><><><><><><><>
 1 dune-universe git+https://github.com/dune-universe/opam-overlays.git
 2 default       https://opam.ocaml.org

λ mirage configure -t unix
λ make depends

using overlay repository mirage: [opam-overlays, mirage-overlays]
[opam-overlays] no changes from git+https://github.com/dune-universe/opam-overlays.git
[NOTE] Repository opam-overlays has been added to the selections of switch dream-mirage-4.14.1 only.
       Run `opam repository add opam-overlays --all-switches|--set-default' to use it in all existing switches, or in newly created switches, respectively.

[mirage-overlays] no changes from git+https://github.com/dune-universe/mirage-opam-overlays.git
[NOTE] Repository mirage-overlays has been added to the selections of switch dream-mirage-4.14.1 only.
       Run `opam repository add mirage-overlays --all-switches|--set-default' to use it in all existing switches, or in newly created switches, respectively.

 ↳ generate lockfile for monorepo dependencies
==> Using 1 locally scanned package as the target.
[WARNING] Unknown variable "ocaml-system:version"
[WARNING] Unknown variable "ocaml-base-compiler:version"
[WARNING] Unknown variable "ocaml-variants:version"
[WARNING] Unknown variable "ocaml-system:version"
[WARNING] Unknown variable "ocaml-base-compiler:version"
[WARNING] Unknown variable "ocaml-variants:version"
[WARNING] Unknown variable "ocaml-system:version"
[WARNING] Unknown variable "ocaml-base-compiler:version"
[WARNING] Unknown variable "ocaml-variants:version"
opam-monorepo: [ERROR] There is no eligible version of cmdliner that matches >= 1.1.0
[WARNING] Unknown variable "ocaml-system:version"
[WARNING] Unknown variable "ocaml-base-compiler:version"
[WARNING] Unknown variable "ocaml-variants:version"
[WARNING] Unknown variable "ocaml-system:version"
[WARNING] Unknown variable "ocaml-base-compiler:version"
[WARNING] Unknown variable "ocaml-variants:version"
opam-monorepo: [WARNING] Couldn't calculate a set of packages to satisfy the request. Note that opam monorepo lock will fail if not all of the project dependencies use dune as their build system, in your project that would be ptime,
                         ocamlfind, logs, fmt,
                         astring. To solve this issue there exists a dune-universe opam-repository which contains dune ports for some opam packages, but it is currently not set in your current switch. If you wish to set it up, run the following command:
opam repository add dune-universe git+https://github.com/dune-universe/opam-overlays.git
[WARNING] Unknown variable "ocaml-system:version"
[WARNING] Unknown variable "ocaml-base-compiler:version"
[WARNING] Unknown variable "ocaml-variants:version"
[WARNING] Unknown variable "ocaml-system:version"
[WARNING] Unknown variable "ocaml-base-compiler:version"
[WARNING] Unknown variable "ocaml-variants:version"
opam-monorepo: [ERROR] Can't find all required versions.
Selected: arp.3.1.0 base-bigarray.base base-bytes.base base-domains.base
          base-nnp.base base-threads.base base-unix.base cppo.1.6.9
          csexp.1.5.2 cstruct.6.2.0 cstruct-lwt.6.2.0 domain-name.0.4.0
          dune.3.7.1 dune-configurator.3.7.1 duration.0.2.1 ethernet.3.2.0
          functoria-runtime.4.3.6 hello-unix.zdev ipaddr.5.5.0
          ipaddr-cstruct.5.5.0 lru.0.3.1 lwt.5.6.1 lwt-dllist.1.0.1
          macaddr.5.5.0 macaddr-cstruct.5.5.0 metrics.0.4.0
          mirage-bootvar-unix.0.1.0 mirage-clock.4.2.0
          mirage-clock-unix.4.2.0 mirage-flow.3.0.0 mirage-logs.1.3.0
          mirage-net.4.0.0 mirage-random.3.0.0 mirage-runtime.4.3.6
          mirage-time.3.0.0 mirage-unix.5.0.1 ocaml-base-compiler.5.0.0
          ocaml-options-vanilla.1 ocplib-endian.1.2 parse-argv.0.2.0
          psq.0.2.1 randomconv.0.1.3 seq.base tcpip.8.0.0
          ocaml-base-compiler&hello-unix ocaml base-domains ocaml
          ocaml-base-compiler
- astring -> (problem)
    No usable implementations:
      astring.0.8.5: Doesn't build with dune
      astring.0.8.4: Doesn't build with dune
      astring.0.8.3: Doesn't build with dune
      astring.0.8.2: Doesn't build with dune
      astring.0.8.1: Doesn't build with dune
      ...
- cmdliner -> (problem)
    functoria-runtime 4.3.6 requires >= 1.1.0
    Rejected candidates:
      cmdliner.0.9.5: Incompatible with restriction: >= 1.1.0
      cmdliner.0.9.4: Incompatible with restriction: >= 1.1.0
      cmdliner.0.9.2: Incompatible with restriction: >= 1.1.0
      cmdliner.1.2.0: Doesn't build with dune
      cmdliner.1.1.1: Doesn't build with dune
      ...
- dream-mirage -> (problem)
    No known implementations at all
- fmt -> (problem)
    No usable implementations:
      fmt.0.9.0: Doesn't build with dune
      fmt.0.8.10: Doesn't build with dune
      fmt.0.8.9: Doesn't build with dune
      fmt.0.8.8: Doesn't build with dune
      fmt.0.8.7: Doesn't build with dune
      ...
- logs -> (problem)
    No usable implementations:
      logs.0.7.0: Doesn't build with dune
      logs.0.6.3: Doesn't build with dune
      logs.0.6.2: Doesn't build with dune
      logs.0.6.1: Doesn't build with dune
      logs.0.6.0: Doesn't build with dune
      ...
- ocaml -> (problem)
    User requested = 4.14.1
    ocaml-base-compiler 5.0.0 requires = 5.0.0
    Rejected candidates:
      ocaml.4.14.1: Incompatible with restriction: = 5.0.0
- ocamlfind -> (problem)
    No usable implementations:
      ocamlfind.1.9.6: Doesn't build with dune
      ocamlfind.1.9.5: Doesn't build with dune
      ocamlfind.1.9.3: Doesn't build with dune
      ocamlfind.1.9.2: Doesn't build with dune
      ocamlfind.1.9.1: Doesn't build with dune
      ...
- ptime -> (problem)
    No usable implementations:
      ptime.1.1.0: Doesn't build with dune
      ptime.1.0.0: Doesn't build with dune
      ptime.0.8.6: Doesn't build with dune
      ptime.0.8.5: Doesn't build with dune
      ptime.0.8.4: Doesn't build with dune
      ...
removing overlay repository [opam-overlays, mirage-overlays]
Repositories removed from the selections of switch dream-mirage-4.14.1. Use '--all' to forget about them altogether.
Repositories removed from the selections of switch dream-mirage-4.14.1. Use '--all' to forget about them altogether.
make[2]: *** [Makefile:36: mirage/hello-unix.opam.locked] Error 1
make[1]: *** [Makefile:39: lock] Error 2
make: *** [Makefile:51: depends] Error 2

I am working in example w-mirage, which I have copied out to its own separate directory. Do you know, by chance, what could be causing this?

As a sanity check,

λ opam info ptime


<><> ptime: information on all versions <><><><><><><><><><><><><><><><><><><><>
name                   ptime
all-installed-versions 1.1.0 [dream-4.14.1 dream-5.0.0 dream-serve-4.14.1 /home/antron/code/style /home/antron/code/serve]
all-versions           0.8.0  0.8.1  0.8.2  0.8.3  0.8.4  0.8.5  0.8.5+dune  0.8.6  1.0.0  1.0.0+dune  1.0.0+dune2  1.1.0  1.1.0+dune

<><> Version-specific details <><><><><><><><><><><><><><><><><><><><><><><><><>
version      1.1.0+dune
repository   dune-universe
url.src      "https://github.com/dune-universe/ptime/releases/download/v1.1.0%2Bdune/ptime-1.1.0.dune.tbz"
url.checksum "sha256=9aa6645808ce539eeafe4eaf781d6d0ae5639c90592cee31d15cf9363acf9234"
             "sha512=0d037fc8f11c25b407f5501bd614dbbadb83fd6dce2fff5c0eeae27a9cd616f69f399f0cb3a04a2b0588cf1866cb16d6d1ae599791509cb995a92d3ae33ad1a0"
homepage     "https://github.com/dune-universe/ptime"
bug-reports  "https://github.com/dbuenzli/ptime/issues"
dev-repo     "git+https://github.com/dune-universe/ptime.git"
authors      "The ptime programmers"
maintainer   "Daniel Bünzli <daniel.buenzl i@erratique.ch>"
license      "ISC"
tags         "time" "posix" "system" "org:erratique"
depends      "dune" "ocaml" {>= "4.08.0"}
synopsis     POSIX time for OCaml
description  Ptime has platform independent POSIX time support in pure OCaml. It
             provides a type to represent a well-defined range of POSIX timestamps
             with picosecond precision, conversion with date-time values,
             conversion with [RFC 3339 timestamps][rfc3339] and pretty printing to
             a human-readable, locale-independent representation.
             The additional Ptime_clock library provides access to a system POSIX
             clock and to the system's current time zone offset.
             Ptime is not a calendar library.
             Ptime has no dependency. Ptime_clock depends on your system library or
             JavaScript runtime system. Ptime and its libraries are distributed
             under the ISC license.
             [rfc3339]: http://tools.ietf.org/html/rfc3339
             Home page: <http://erratique.ch/software/ptime>

I see the +dune versions in the output, so why is make depends saying that there isn't a version of, for instance, ptime that builds with Dune?

@aantron
Copy link
Owner

aantron commented May 17, 2023

Also

λ opam --version
2.1.4

@dinosaure
Copy link
Contributor

I think the problem is more about dream-mirage:

- dream-mirage -> (problem)
    No known implementations at all

Did you pin the dream-mirage package to let opam and the 0install-solver to know about this package?

@aantron
Copy link
Owner

aantron commented May 19, 2023

I did and do have it pinned. To be sure:

λ rm -rf Makefile _build/ dist dune dune-project dune-workspace dune.build dune.config mirage


λ ls

README.md  config.ml  unikernel.ml

λ opam pin list

dream-mirage.~dev  (uninstalled)  git  git+file:///home/antron/code/dreamworld/dream#patch-1

λ opam repo list

[NOTE] These are the repositories in use by the current switch. Use '--all' to see all configured repositories.

<><> Repository configuration for switch dream-mirage-4.14.1 ><><><><><><><><><>
 1 dune-universe git+https://github.com/dune-universe/opam-overlays.git
 2 default       https://opam.ocaml.org

λ mirage --version

v4.3.6

λ ocaml -version

The OCaml toplevel, version 4.14.1

λ which ocaml

/home/antron/.opam/dream-mirage-4.14.1/bin/ocaml

λ mirage configure -t unix


λ make depends

using overlay repository mirage: [opam-overlays, mirage-overlays]
[opam-overlays] no changes from git+https://github.com/dune-universe/opam-overlays.git
[NOTE] Repository opam-overlays has been added to the selections of switch dream-mirage-4.14.1 only.
       Run `opam repository add opam-overlays --all-switches|--set-default' to use it in all existing switches, or in newly created switches, respectively.

[mirage-overlays] no changes from git+https://github.com/dune-universe/mirage-opam-overlays.git
[NOTE] Repository mirage-overlays has been added to the selections of switch dream-mirage-4.14.1 only.
       Run `opam repository add mirage-overlays --all-switches|--set-default' to use it in all existing switches, or in newly created switches, respectively.

 ↳ generate lockfile for monorepo dependencies
==> Using 1 locally scanned package as the target.
[WARNING] Unknown variable "ocaml-system:version"
[WARNING] Unknown variable "ocaml-base-compiler:version"
[WARNING] Unknown variable "ocaml-variants:version"
[WARNING] Unknown variable "ocaml-system:version"
[WARNING] Unknown variable "ocaml-base-compiler:version"
[WARNING] Unknown variable "ocaml-variants:version"
[WARNING] Unknown variable "ocaml-system:version"
[WARNING] Unknown variable "ocaml-base-compiler:version"
[WARNING] Unknown variable "ocaml-variants:version"
opam-monorepo: [ERROR] There is no eligible version of cmdliner that matches >= 1.1.0
[WARNING] Unknown variable "ocaml-system:version"
[WARNING] Unknown variable "ocaml-base-compiler:version"
[WARNING] Unknown variable "ocaml-variants:version"
[WARNING] Unknown variable "ocaml-system:version"
[WARNING] Unknown variable "ocaml-base-compiler:version"
[WARNING] Unknown variable "ocaml-variants:version"
opam-monorepo: [WARNING] Couldn't calculate a set of packages to satisfy the request. Note that opam monorepo lock will fail if not all of the project dependencies use dune as their build system, in your project that would be ptime,
                         ocamlfind, logs, fmt,
                         astring. To solve this issue there exists a dune-universe opam-repository which contains dune ports for some opam packages, but it is currently not set in your current switch. If you wish to set it up, run the following command:
opam repository add dune-universe git+https://github.com/dune-universe/opam-overlays.git
[WARNING] Unknown variable "ocaml-system:version"
[WARNING] Unknown variable "ocaml-base-compiler:version"
[WARNING] Unknown variable "ocaml-variants:version"
[WARNING] Unknown variable "ocaml-system:version"
[WARNING] Unknown variable "ocaml-base-compiler:version"
[WARNING] Unknown variable "ocaml-variants:version"
opam-monorepo: [ERROR] Can't find all required versions.
Selected: arp.3.1.0 base-bigarray.base base-bytes.base base-domains.base
          base-nnp.base base-threads.base base-unix.base cppo.1.6.9
          csexp.1.5.2 cstruct.6.2.0 cstruct-lwt.6.2.0 domain-name.0.4.0
          dune.3.7.1 dune-configurator.3.7.1 duration.0.2.1 ethernet.3.2.0
          functoria-runtime.4.3.6 hello-unix.zdev ipaddr.5.5.0
          ipaddr-cstruct.5.5.0 lru.0.3.1 lwt.5.6.1 lwt-dllist.1.0.1
          macaddr.5.5.0 macaddr-cstruct.5.5.0 metrics.0.4.0
          mirage-bootvar-unix.0.1.0 mirage-clock.4.2.0
          mirage-clock-unix.4.2.0 mirage-flow.3.0.0 mirage-logs.1.3.0
          mirage-net.4.0.0 mirage-random.3.0.0 mirage-runtime.4.3.6
          mirage-time.3.0.0 mirage-unix.5.0.1 ocaml-base-compiler.5.0.0
          ocaml-options-vanilla.1 ocplib-endian.1.2 parse-argv.0.2.0
          psq.0.2.1 randomconv.0.1.3 seq.base tcpip.8.0.0
          ocaml-base-compiler&hello-unix ocaml base-domains ocaml
          ocaml-base-compiler
- astring -> (problem)
    No usable implementations:
      astring.0.8.5: Doesn't build with dune
      astring.0.8.4: Doesn't build with dune
      astring.0.8.3: Doesn't build with dune
      astring.0.8.2: Doesn't build with dune
      astring.0.8.1: Doesn't build with dune
      ...
- cmdliner -> (problem)
    functoria-runtime 4.3.6 requires >= 1.1.0
    Rejected candidates:
      cmdliner.0.9.5: Incompatible with restriction: >= 1.1.0
      cmdliner.0.9.4: Incompatible with restriction: >= 1.1.0
      cmdliner.0.9.2: Incompatible with restriction: >= 1.1.0
      cmdliner.1.2.0: Doesn't build with dune
      cmdliner.1.1.1: Doesn't build with dune
      ...
- dream-mirage -> (problem)
    No known implementations at all
- fmt -> (problem)
    No usable implementations:
      fmt.0.9.0: Doesn't build with dune
      fmt.0.8.10: Doesn't build with dune
      fmt.0.8.9: Doesn't build with dune
      fmt.0.8.8: Doesn't build with dune
      fmt.0.8.7: Doesn't build with dune
      ...
- logs -> (problem)
    No usable implementations:
      logs.0.7.0: Doesn't build with dune
      logs.0.6.3: Doesn't build with dune
      logs.0.6.2: Doesn't build with dune
      logs.0.6.1: Doesn't build with dune
      logs.0.6.0: Doesn't build with dune
      ...
- ocaml -> (problem)
    User requested = 4.14.1
    ocaml-base-compiler 5.0.0 requires = 5.0.0
    Rejected candidates:
      ocaml.4.14.1: Incompatible with restriction: = 5.0.0
- ocamlfind -> (problem)
    No usable implementations:
      ocamlfind.1.9.6: Doesn't build with dune
      ocamlfind.1.9.5: Doesn't build with dune
      ocamlfind.1.9.3: Doesn't build with dune
      ocamlfind.1.9.2: Doesn't build with dune
      ocamlfind.1.9.1: Doesn't build with dune
      ...
- ptime -> (problem)
    No usable implementations:
      ptime.1.1.0: Doesn't build with dune
      ptime.1.0.0: Doesn't build with dune
      ptime.0.8.6: Doesn't build with dune
      ptime.0.8.5: Doesn't build with dune
      ptime.0.8.4: Doesn't build with dune
      ...
removing overlay repository [opam-overlays, mirage-overlays]
Repositories removed from the selections of switch dream-mirage-4.14.1. Use '--all' to forget about them altogether.
Repositories removed from the selections of switch dream-mirage-4.14.1. Use '--all' to forget about them altogether.
make[2]: *** [Makefile:36: mirage/hello-unix.opam.locked] Error 1
make[1]: *** [Makefile:39: lock] Error 2
make: *** [Makefile:51: depends] Error 2

To additionally check:

λ opam info ptime                                                                                                                                                       2


<><> ptime: information on all versions <><><><><><><><><><><><><><><><><><><><>
name                   ptime
all-installed-versions 1.1.0 [dream-4.14.1 dream-5.0.0 dream-serve-4.14.1 /home/antron/code/style /home/antron/code/serve dream-social-4.14.1]
all-versions           0.8.0  0.8.1  0.8.2  0.8.3  0.8.4  0.8.5  0.8.5+dune  0.8.6  1.0.0  1.0.0+dune  1.0.0+dune2  1.1.0  1.1.0+dune

<><> Version-specific details <><><><><><><><><><><><><><><><><><><><><><><><><>
version      1.1.0+dune
repository   dune-universe
url.src      "https://github.com/dune-universe/ptime/releases/download/v1.1.0%2Bdune/ptime-1.1.0.dune.tbz"
url.checksum "sha256=9aa6645808ce539eeafe4eaf781d6d0ae5639c90592cee31d15cf9363acf9234"
             "sha512=0d037fc8f11c25b407f5501bd614dbbadb83fd6dce2fff5c0eeae27a9cd616f69f399f0cb3a04a2b0588cf1866cb16d6d1ae599791509cb995a92d3ae33ad1a0"
homepage     "https://github.com/dune-universe/ptime"
bug-reports  "https://github.com/dbuenzli/ptime/issues"
dev-repo     "git+https://github.com/dune-universe/ptime.git"
authors      "The ptime programmers"
maintainer   "Daniel Bünzli <daniel.buenzl i@erratique.ch>"
license      "ISC"
tags         "time" "posix" "system" "org:erratique"
depends      "dune" "ocaml" {>= "4.08.0"}
synopsis     POSIX time for OCaml
description  Ptime has platform independent POSIX time support in pure OCaml. It
             provides a type to represent a well-defined range of POSIX timestamps
             with picosecond precision, conversion with date-time values,
             conversion with [RFC 3339 timestamps][rfc3339] and pretty printing to
             a human-readable, locale-independent representation.
             The additional Ptime_clock library provides access to a system POSIX
             clock and to the system's current time zone offset.
             Ptime is not a calendar library.
             Ptime has no dependency. Ptime_clock depends on your system library or
             JavaScript runtime system. Ptime and its libraries are distributed
             under the ISC license.
             [rfc3339]: http://tools.ietf.org/html/rfc3339
             Home page: <http://erratique.ch/software/ptime>

λ opam info dream-mirage


<><> dream-mirage: information on all versions ><><><><><><><><><><><><><><><><>
name         dream-mirage
all-versions ~dev

<><> Version-specific details <><><><><><><><><><><><><><><><><><><><><><><><><>
version     ~dev
pin         git+file:///home/antron/code/dreamworld/dream#patch-1
source-hash fcc20d00
url.src     "git+file:///home/antron/code/dreamworld/dream#patch-1"
homepage    "https://github.com/aantron/dream"
doc         "https://aantron.github.io/dream"
bug-reports "https://github.com/aantron/dream/issues"
dev-repo    "git+https://github.com/aantron/dream.git"
authors     "Anton Bachin <antonbachin@yahoo.com>"
maintainer  "Anton Bachin <antonbachin@yahoo.com>"
license     "MIT"
tags        "http" "web" "framework" "websocket" "graphql" "server" "http2" "tls"
depends     "bigarray-compat"
            "bigstringaf"
            "digestif" {>= "1.0.0"}
            "dream"
            "dream-httpaf"
            "dream-pure"
            "dune" {>= "2.7.0"}
            "duration"
            "emile" {>= "1.1"}
            "letsencrypt" {>= "0.3.0"}
            "lwt"
            "lwt_ppx" {>= "1.2.2"}
            "mimic" {>= "0.0.6"}
            "mirage-time"
            "rresult"
            "tcpip"
            "tls-mirage"
synopsis    Tidy, feature-complete Web framework
description Dream is a feature-complete Web framework with a simple programming
            model and no boilerplate. It provides only two data types, request and
            response.
            Almost everything else is either a built-in OCaml type, or an
            abbreviation for a bare function. For example, a Web app, known in
            Dream as a handler, is just an ordinary function from requests to
            responses. And a middleware is then just a function from handlers to
            handlers.
            Within this model, Dream adds:
            - Session management with pluggable back ends.
            - A fully composable router.
            - Support for HTTP/1.1, HTTP/2, and HTTPS.
            - WebSockets.
            - GraphQL, including subscriptions and a built-in GraphiQL editor.
            - SQL connection pool helpers.
            - Server-side HTML templates.
            - Automatic secure handling of cookies and forms.
            - Unified, internationalization-friendly error handling.
            - A neat log, and OCaml runtime configuration.
            - Helpers for Web formats, such as Base64url, and a modern cipher.
            Because of the simple programming model, everything is optional and
            composable. It is trivailly possible to strip Dream down to just a
            bare driver of the various HTTP protocols.
            Dream is presented as a single module, whose API is documented on one
            page. In addition, Dream comes with a large number of examples.
            Security topics are introduced throughout, wherever they are
            applicable.

@TheLortex
Copy link
Contributor

It's super weird because opam-monorepo doesn't see packages from the dune-universe repository. But they seem to be added by the makefile:

using overlay repository mirage: [opam-overlays, mirage-overlays]
[opam-overlays] no changes from git+https://github.com/dune-universe/opam-overlays.git
[NOTE] Repository opam-overlays has been added to the selections of switch dream-mirage-4.14.1 only.
       Run `opam repository add opam-overlays --all-switches|--set-default' to use it in all existing switches, or in newly created switches, respectively.

[mirage-overlays] no changes from git+https://github.com/dune-universe/mirage-opam-overlays.git
[NOTE] Repository mirage-overlays has been added to the selections of switch dream-mirage-4.14.1 only.
       Run `opam repository add mirage-overlays --all-switches|--set-default' to use it in all existing switches, or in newly created switches, respectively.

@dysinger
Copy link

dysinger commented Oct 6, 2023

@aantron, I have taken the time to show that @tmcgilchrist patch works with a demo.

Here I started with master and cherry-picked @tmcgilchrist's ebb6d57 commit.

~/src/ml/dream> git checkout -b test upstream/master
branch 'test' set up to track 'upstream/master'.
Switched to a new branch 'test'
~/src/ml/dream> git cherry-pick ebb6d5705bcdad4ed535641fd2437a32d6e20aa0
[test 0f112ee] Update Dream_mirage with remove deprecated values changes.
 Author: Tim McGilchrist <timmcgil@gmail.com>
 Date: Tue May 16 10:49:02 2023 +1000
 2 files changed, 22 insertions(+), 40 deletions(-)
~/src/ml/dream> git submodule update

Then I added the following Dockerfile to the base of Dream repo:

ARG ocaml
FROM ocaml/opam:debian-unstable-ocaml-$ocaml as base

# INSTALL OPAM 2.1 & MIRAGE
ARG mirage
ADD https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh /tmp/
RUN sudo chmod 755 /tmp/install.sh
RUN sudo sed -i 's|read BINDIR|BINDIR=/usr/local/bin|' /tmp/install.sh
RUN /tmp/install.sh
RUN opam install mirage=$mirage

# COPY & PIN THIS REPO
COPY ./ /usr/local/src/dream/
RUN opam pin -n dream        /usr/local/src/dream
RUN opam pin -n dream-pure   /usr/local/src/dream
RUN opam pin -n dream-httpaf /usr/local/src/dream
RUN opam pin -n dream-mirage /usr/local/src/dream

# CLONE THE EXAMPLE
WORKDIR /usr/local/src/example
RUN sudo chown $(whoami) /usr/local/src/example
RUN rsync -r /usr/local/src/dream/example/w-mirage/ /usr/local/src/example/

# COMPILE KVM IMAGE
FROM base as hvt
RUN opam exec -- mirage configure -t hvt
RUN opam exec -- make

# COMPILE XEN IMAGE
FROM base as xen
RUN opam exec -- mirage configure -t xen
RUN opam exec -- make

# COMPILE VIRTIO IMAGE
FROM base as virtio
RUN opam exec -- mirage configure -t virtio
RUN opam exec -- make

# COMPILE POSIX EXE
FROM base as unix
RUN opam exec -- mirage configure -t unix
RUN opam exec -- make

# RUNTIME POSIX IMAGE
FROM debian:unstable as runtime
RUN apt-get update ; apt-get install -y libev4 libgmp10
COPY --from=unix /usr/local/src/example/dist/hello /usr/local/bin/hello
ENTRYPOINT /usr/local/bin/hello
EXPOSE 8080

I used Docker to build, with each version of OCaml, a dream-mirage 'hello' unikernel (or 4.)

docker build --build-arg ocaml=4.10 --build-arg mirage=4.4.0  --tag dream-mirage-hello:ocaml-4.10+mirage-4.4.0 ./.
docker build --build-arg ocaml=4.12 --build-arg mirage=4.4.0  --tag dream-mirage-hello:ocaml-4.12+mirage-4.4.0 ./.
docker build --build-arg ocaml=4.14 --build-arg mirage=4.4.0  --tag dream-mirage-hello:ocaml-4.14+mirage-4.4.0 ./.
docker build --build-arg ocaml=5.0  --build-arg mirage=4.4.0  --tag dream-mirage-hello:ocaml-5.0+mirage-4.4.0  ./.
docker build --build-arg ocaml=5.1  --build-arg mirage=4.4.0  --tag dream-mirage-hello:ocaml-5.1+mirage-4.4.0  ./.

If it compiles it will run with docker run like so:

> docker run -i -t --rm -p 8080:8080 dream-mirage-hello:ocaml-4.14+mirage-4.4.0
2023-10-06 11:37:39 +00:00: INF [tcpip-stack-socket] Dual IPv4 and IPv6 socket stack: connect

The following is a table of what worked and what did not:

Dream OCaml Mirage Mirage Compiled? Example Compiled? Note
~dev 4.08 4.4.0 No No resolve error
" 4.10 4.4.0 Yes Yes/No posix works, ocaml-solo5: Requires ocaml >= 4.12.1 & < 4.15.0
" 4.12 4.4.4 Yes Yes  
" 4.14 4.4.0 Yes Yes  
" 5.0 4.4.0 Yes Yes/No posix works, ocaml-solo5: Requires ocaml >= 4.12.1 & < 4.15.0
" 5.1 4.4.0 Yes No resolve error
" 5.2 4.4.0     5.1 isn't working so I didn't bother with 5.2

In summary, I vote to at least cherry-pick ebb6d57. Nothing with mirage works without it.

@dysinger
Copy link

I'm running a topgit stack of patches for Dream, so I am able to do my thing, but I would love to see Mirage working again in master.

@aantron
Copy link
Owner

aantron commented Oct 31, 2023

I was able to get this working now and I'm ready to merge. Thank you and sorry for the huge delay!

Why is there a bound of 0.0.6 on Mimic now?

As for Lwt_ppx, it seems like that bound would have to be fixed upstream. If that's not an option, we can still merge it, though. If we need to do it in Dream, would it be better to put the 2.1.0 bound into dream-mirage.opam rather than dream.opam?

@aantron
Copy link
Owner

aantron commented Nov 2, 2023

I reverted the Lwt_ppx constraint change, because (1) I was unable to reproduce the problem it was trying to fix, (2) to first appearances, it seems like it should be addressed upstream and not in Dream, could be wrong about that, (3) I could not make sense of the error message "complex open are not supported before OCaml 4.08" in light of the fact that Dream has OCaml 4.08 as a lower bound.

I was able to lower the mimic constraint to 0.0.5, as required by the vendored paf. Everything still appears to build and work.

@aantron aantron merged commit f5c8ba0 into aantron:master Nov 2, 2023
10 of 13 checks passed
@aantron
Copy link
Owner

aantron commented Nov 2, 2023

Thank you!

Please send more PRs, or link me to any public forks that I can cherry-pick more patches from!

@tmcgilchrist
Copy link
Contributor Author

Thanks for merging this fix @aantron

I have not been doing any Dream / Mirage work recently and forgot about this PR. The main users of this functionality are https://github.com/ocurrent/mirage-ci, https://github.com/mirage/mirage-www and the linked ocaml-matrix library.

I could not make sense of the error message "complex open are not supported before OCaml 4.08" in light of the fact that Dream has OCaml 4.08 as a lower bound.

I think it was caused by lwt_ppx using an old version of the ocaml parse tree to do transforms but I can't reproduce it anymore either.

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

Successfully merging this pull request may close these issues.

5 participants