Is dream incompatible with eio?

I’m not sure what I’m doing wrong. With opam, I can not seem to install both dream (which I am currently working through examples) and eio (which try-eio depends on).

I’m not sure how to debug this issue. Advice ?

Can you share the error you are getting? It’s hard to know what the issue is without it.

Dream doesn’t natively use EIO, rather it uses LWT but you can safely mix EIO and LWT using lwt_eio

1 Like

I’m not sure what’s going on. If I try to install dream, it wants to remove eio. Is there a different command I can type to provide more information ?


$ opam install dream
[NOTE] External dependency handling not supported for OS family 'nixos'.
       You can disable this check using 'opam option --global depext=false'
The following actions will be performed:
  ⊘ remove    base-nnp                    base               [uses base-domains]
  ⊘ remove    eio                         0.8.1              [conflicts with ocaml]
  ⊘ remove    base-domains                base               [conflicts with ocaml]
  ↘ downgrade ocaml-base-compiler         5.0.0 to 4.14.1    [required by ocaml]
  ↘ downgrade ocaml-config                3 to 2             [required by ocaml]
  ↘ downgrade ocaml                       5.0.0 to 4.14.1    [required by dream]
  ↻ recompile seq                         base               [uses ocaml]
  ↻ recompile ocamlfind                   1.9.6              [uses ocaml]
  ↻ recompile ocamlbuild                  0.14.2             [uses ocaml]
  ↻ recompile mirage-no-xen               1                  [uses ocaml]
  ↻ recompile mirage-no-solo5             1                  [uses ocaml]

Hmm, is the issue eio wants OCaml 5, and dream wants OCaml < 5 ?

dream 1.0.0~alpha3 requires <5.0, but alpha4 (which is in the opam-repository as well) does not have an upward bound on ocaml. Have you run opam update?

edit: I’ve just tried opam pin dream "1.0.0~alpha", and got:

dream is now pinned to version 1.0.0~alpha4

[ERROR] Package conflict!
  * No agreement on the version of ocaml:
    - (invariant) → ocaml >= 5.0.0
    - dream → dream-httpaf → ocaml < 5.0
    You can temporarily relax the switch invariant with `--update-invariant'
  * No agreement on the version of ocaml:
    - (invariant) → ocaml >= 5.0.0
    - dream → dream-httpaf → ocaml < 5.05

So there are still pieces of dream that are not compatible with ocaml5 it seems.

There has been an attempt to port Dream to Eio instead of Lwt, I suspect before that is done we won’t able to see the true benefits of Eio.

I actually don’t need EIO support in Dream. My problem is:

  1. I have one dune project that depends on eio.

  2. I have a second dune project that depends on Dream.

  3. I have one global opam config.

Question: Is there a way to have separate per-project opam repos ?

1 Like

Hmm, as far as I know, no. And that sounds like a pretty complex setup. If Dream is not a hard requirement, maybe you could try Antonio Monteiro’s Piaf library, which has been ported to run on top of Eio. Although, the version 0.1.0 published on opam is the old one pre-Eio. Right now the only feasible way to use the new Eio port would be with Nix, but that would require quite a bit of investment.

You can create a per-project opam switch, but you’ll have to install all dependencies there (no sharing with the global opam switch, will likely build a new compiler too), try opam switch create ./ in one of the project’s dirs, see: opam - new opam features: local switches

Another option is to have 2 global opam switches, and use ‘opam switch link second-switch ./’ to change to that switch automatically when inside the directory (depending on your shell setup you may have to do eval $(opam env) when cd-ing into the directory.

Even though Piaf requires a few local pins, it wouldn’t be very useful if it were only installable from Nix. I just updated the OPAM files and added an OPAM GH Actions job to make sure it remains installable without user-overridden modification


Yes, these are called “local switches” and can be done with OPAM. In general I recommend doing this per-project to avoid capturing unintended dependencies and be able to upgrade dependencies without affecting other projects.

In opam, a “repo” is a collection of installable packages, specified in a big folder with a bunch of .opam files. You can see the default community one here : GitHub - ocaml/opam-repository: Main public package repository for opam, the source package manager of OCaml.. What you want is a switch, people above have explained that quite well.

Dream itself is compatible with OCaml 5, but for various reasons it had to vendor a project, and the vendored code was not compatible with OCaml 5. There is a release of Dream awaiting merge into opam (after I fix some package constraints) that fixes this, and you’ll be able to use Dream and Eio on OCaml 5, including just having them installed at the same time, even without the PR that was linked.