Problems installing domainslib with multicore OCaml

Hello again and my apologies for pestering you with this one more time. Three days ago, when I was doing opam update && opam upgrade, I got this output (I run the updates daily):

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><>  🐫
[multicore] no changes from git+https://github.com/ocaml-multicore/multicore-opam.git
[default] synchronised from https://opam.ocaml.org
Now run 'opam upgrade' to apply any package updates.
The following actions will be performed:
  β†— upgrade domainslib 0.2.2 to 0.3.0

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
[domainslib.0.3.0] found in cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
[ERROR] The compilation of domainslib failed at "/Users/dimi/.opam/opam-init/hooks/sandbox.sh build dune build -p domainslib".

#=== ERROR while compiling domainslib.0.3.0 ===================================#
# context     2.0.8 | macos/x86_64 | ocaml-variants.4.12.0+domains+effects | git+https://github.com/ocaml-multicore/multicore-opam.git
# path        ~/.opam/4.12.0+domains+effects/.opam-switch/build/domainslib.0.3.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p domainslib
# exit-code   1
# env-file    ~/.opam/log/domainslib-47297-1872ec.env
# output-file ~/.opam/log/domainslib-47297-1872ec.out
### output ###
# Error: Unbound module Mutex
# [...]
# (cd _build/default && /Users/dimi/.opam/4.12.0+domains+effects/bin/ocamlc.opt -w -40 -g -bin-annot -I lib/.domainslib.objs/byte -no-alias-deps -open Domainslib__ -o lib/.domainslib.objs/byte/domainslib__Multi_channel.cmo -c -impl lib/multi_channel.ml)
# File "lib/multi_channel.ml", line 20, characters 9-16:
# 20 |   mutex: Mutex.t;
#               ^^^^^^^
# Error: Unbound module Mutex
#     ocamlopt lib/.domainslib.objs/native/domainslib__Chan.{cmx,o} (exit 2)
# (cd _build/default && /Users/dimi/.opam/4.12.0+domains+effects/bin/ocamlopt.opt -w -40 -g -I lib/.domainslib.objs/byte -I lib/.domainslib.objs/native -intf-suffix .ml -no-alias-deps -open Domainslib__ -o lib/.domainslib.objs/native/domainslib__Chan.cmx -c -impl lib/chan.ml)
# File "lib/chan.ml", line 4, characters 9-16:
# 4 |   mutex: Mutex.t;
#              ^^^^^^^
# Error: Unbound module Mutex



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
β”Œβ”€ The following actions failed
β”‚ Ξ» build domainslib 0.3.0
└─
╢─ No changes have been performed

This looks like a consequence of some recent updates in the compiler and domainslib. Mutex, Condition Variable and Semaphore were added to stdlib modules (ocaml-multicore#548) and a work stealing implementation for Domainslib Task (domainslib#29).

My recommendation is to reinstall the compiler with opam reinstall ocaml-variants and run the updates after the compiler is updated.

1 Like

Here’s what happened:

opam reinstall ocaml-variants                                                                                                                                                                           ─╯
The following actions will be performed:
  ↻ recompile ocaml-variants      4.12.0+domains+effects
  ↻ recompile ocaml-config        2                      [uses ocaml-variants]
  ↻ recompile ocaml               4.12.0                 [uses ocaml-variants]
  ↻ recompile ocamlfind           1.9.1                  [uses ocaml]
  ↻ recompile dune                2.8.5                  [uses ocaml]
  ↻ recompile base-domains        base                   [uses ocaml-variants]
  ↻ recompile stdlib-shims        0.3.0                  [uses ocaml]
  ↻ recompile result              1.5                    [uses ocaml]
  ↻ recompile pp                  1.1.2                  [uses ocaml]
  ↻ recompile easy-format         1.3.2                  [uses ocaml]
  ↻ recompile dune-build-info     2.8.5                  [uses dune]
  ↻ recompile csexp               1.5.1                  [uses ocaml]
  ↻ recompile cppo                1.6.7                  [uses ocaml]
  ↻ recompile domainslib          0.2.2                  [uses base-domains]
  ↻ recompile base-effects        base                   [uses ocaml-variants]
  ↻ recompile biniou              1.2.1                  [uses ocaml]
  ↻ recompile yojson              1.7.0                  [uses ocaml]
  ↻ recompile ppx_yojson_conv_lib v0.14.0                [uses ocaml]
  ↻ recompile dot-merlin-reader   4.1                    [uses ocaml]
  ↻ recompile ocaml-lsp-server    1.6.1                  [uses ocaml]
  ↻ recompile merlin              4.2-412                [uses ocaml]
===== ↻ 21 =====
Do you want to continue? [Y/n] y

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
[biniou.1.2.1] found in cache
[cppo.1.6.7] found in cache
[csexp.1.5.1] found in cache
[domainslib.0.2.2] found in cache
[dot-merlin-reader.4.1] found in cache
Processing  7/21:
[dune.2.8.5] found in cache
[dune-build-info.2.8.5] found in cache
[easy-format.1.3.2] found in cache
[merlin.4.2-412] found in cache
[ocaml-lsp-server.1.6.1] found in cache
[ocamlfind.1.9.1] found in cache
[pp.1.1.2] found in cache
[ppx_yojson_conv_lib.v0.14.0] found in cache
[result.1.5] found in cache
[stdlib-shims.0.3.0] found in cache
[yojson.1.7.0] found in cache
[ocaml-variants.4.12.0+domains+effects] synchronised from git+https://github.com/ocaml-multicore/ocaml-multicore.git#4.12+domains+effects

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
⊘ removed   base-effects.base
⊘ removed   domainslib.0.2.2
⊘ removed   base-domains.base
⊘ removed   merlin.4.2-412
⊘ removed   ocaml-lsp-server.1.6.1
⊘ removed   dot-merlin-reader.4.1
⊘ removed   csexp.1.5.1
⊘ removed   dune-build-info.2.8.5
⊘ removed   ocamlfind.1.9.1
⊘ removed   pp.1.1.2
⊘ removed   ppx_yojson_conv_lib.v0.14.0
⊘ removed   result.1.5
⊘ removed   stdlib-shims.0.3.0
⊘ removed   yojson.1.7.0
⊘ removed   biniou.1.2.1
⊘ removed   cppo.1.6.7
⊘ removed   easy-format.1.3.2
⊘ removed   dune.2.8.5
⊘ removed   ocaml.4.12.0
⊘ removed   ocaml-config.2
⊘ removed   ocaml-variants.4.12.0+domains+effects
βˆ— installed ocaml-variants.4.12.0+domains+effects
βˆ— installed ocaml-config.2
βˆ— installed ocaml.4.12.0
βˆ— installed base-domains.base
βˆ— installed base-effects.base
βˆ— installed ocamlfind.1.9.1
βˆ— installed dune.2.8.5
[ERROR] The compilation of domainslib failed at "/Users/dimi/.opam/opam-init/hooks/sandbox.sh build dune build -p domainslib".
βˆ— installed csexp.1.5.1
βˆ— installed stdlib-shims.0.3.0
βˆ— installed result.1.5
βˆ— installed pp.1.1.2
βˆ— installed easy-format.1.3.2
βˆ— installed dune-build-info.2.8.5
βˆ— installed cppo.1.6.7
βˆ— installed biniou.1.2.1
βˆ— installed yojson.1.7.0
βˆ— installed ppx_yojson_conv_lib.v0.14.0
βˆ— installed dot-merlin-reader.4.1
βˆ— installed merlin.4.2-412
βˆ— installed ocaml-lsp-server.1.6.1

#=== ERROR while compiling domainslib.0.2.2 ===================================#
# context     2.0.8 | macos/x86_64 | ocaml-variants.4.12.0+domains+effects | git+https://github.com/ocaml-multicore/multicore-opam.git
# path        ~/.opam/4.12.0+domains+effects/.opam-switch/build/domainslib.0.2.2
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p domainslib
# exit-code   1
# env-file    ~/.opam/log/domainslib-87730-ff9695.env
# output-file ~/.opam/log/domainslib-87730-ff9695.out
### output ###
# [...]
#       ocamlc lib/.domainslib.objs/byte/domainslib__Chan.{cmo,cmt} (exit 2)
# (cd _build/default && /Users/dimi/.opam/4.12.0+domains+effects/bin/ocamlc.opt -w -40 -g -bin-annot -I lib/.domainslib.objs/byte -intf-suffix .ml -no-alias-deps -open Domainslib__ -o lib/.domainslib.objs/byte/domainslib__Chan.cmo -c -impl lib/chan.ml)
# File "lib/chan.ml", line 38, characters 20-36:
# 38 |               then (Domain.Sync.wait (); true)
#                          ^^^^^^^^^^^^^^^^
# Error: Unbound value Domain.Sync.wait
#     ocamlopt lib/.domainslib.objs/native/domainslib__Chan.{cmx,o} (exit 2)
# (cd _build/default && /Users/dimi/.opam/4.12.0+domains+effects/bin/ocamlopt.opt -w -40 -g -I lib/.domainslib.objs/byte -I lib/.domainslib.objs/native -intf-suffix .ml -no-alias-deps -open Domainslib__ -o lib/.domainslib.objs/native/domainslib__Chan.cmx -c -impl lib/chan.ml)
# File "lib/chan.ml", line 38, characters 20-36:
# 38 |               then (Domain.Sync.wait (); true)
#                          ^^^^^^^^^^^^^^^^
# Error: Unbound value Domain.Sync.wait



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
β”Œβ”€ The following actions failed
β”‚ Ξ» build domainslib 0.2.2
└─
β”Œβ”€ The following changes have been performed
β”‚ ⊘ remove    domainslib          0.2.2
β”‚ ↻ recompile base-domains        base
β”‚ ↻ recompile base-effects        base
β”‚ ↻ recompile biniou              1.2.1
β”‚ ↻ recompile cppo                1.6.7
β”‚ ↻ recompile csexp               1.5.1
β”‚ ↻ recompile dot-merlin-reader   4.1
β”‚ ↻ recompile dune                2.8.5
β”‚ ↻ recompile dune-build-info     2.8.5
β”‚ ↻ recompile easy-format         1.3.2
β”‚ ↻ recompile merlin              4.2-412
β”‚ ↻ recompile ocaml               4.12.0
β”‚ ↻ recompile ocaml-config        2
β”‚ ↻ recompile ocaml-lsp-server    1.6.1
β”‚ ↻ recompile ocaml-variants      4.12.0+domains+effects
β”‚ ↻ recompile ocamlfind           1.9.1
β”‚ ↻ recompile pp                  1.1.2
β”‚ ↻ recompile ppx_yojson_conv_lib v0.14.0
β”‚ ↻ recompile result              1.5
β”‚ ↻ recompile stdlib-shims        0.3.0
β”‚ ↻ recompile yojson              1.7.0
└─

<><> merlin.4.2-412 installed successfully ><><><><><><><><><><><><><><><><>  🐫
=> merlin installed.

   Quick setup for VIM
   -------------------
   Append this to your .vimrc to add merlin to vim's runtime-path:
     let g:opamshare = substitute(system('opam var share'),'\n$','','''')
     execute "set rtp+=" . g:opamshare . "/merlin/vim"

   Also run the following line in vim to index the documentation:
     :execute "helptags " . g:opamshare . "/merlin/vim/doc"

   Quick setup for EMACS
   -------------------
   Add opam emacs directory to your load-path by appending this to your .emacs:
     (let ((opam-share (ignore-errors (car (process-lines "opam" "config" "var" "share")))))
      (when (and opam-share (file-directory-p opam-share))
       ;; Register Merlin
       (add-to-list 'load-path (expand-file-name "emacs/site-lisp" opam-share))
       (autoload 'merlin-mode "merlin" nil t nil)
       ;; Automatically start it in OCaml buffers
       (add-hook 'tuareg-mode-hook 'merlin-mode t)
       (add-hook 'caml-mode-hook 'merlin-mode t)
       ;; Use opam switch to lookup ocamlmerlin binary
       (setq merlin-command 'opam)))

   Take a look at https://github.com/ocaml/merlin for more information

   Quick setup with opam-user-setup
   --------------------------------

   Opam-user-setup support Merlin.

     $ opam user-setup install

   should take care of basic setup.
   See https://github.com/OCamlPro/opam-user-setup
=> Since version 4.2, Merlin integration with completion packages company
   and auto-complete has moved to separate modules. Make sure to add
   `(require 'merlin-company)` or `(require 'merlin-ac)` to your emacs
   configuration if you were using one of these.

The former state can be restored with:
    opam switch import "/Users/dimi/.opam/4.12.0+domains+effects/.opam-switch/backup/state-20210614072953.export"
Or you can retry to install your package selection with:
    opam install --restore

Have you done an opam update recently @dimitarvp? There is a 0.3.0 of domainslib released which uses the new Mutex and Condition instead of Domain.Sync.wait: Release Domainslib 0.3.0 Β· ocaml-multicore/domainslib Β· GitHub

It’s packaged up in the multicore-opam repo, so a opam update; opam install domainslib should do the trick (and you should get 0.3.0). Let us know if that’s not working for some reason.

1 Like

I run this daily:

opam update
opam upgrade -y

Here’s what I have installed:

opam switch
#  switch                  compiler                               description
   4.12.0                  ocaml-base-compiler.4.12.0             4.12.0
β†’  4.12.0+domains+effects  ocaml-variants.4.12.0+domains+effects  4.12.0+domains+effects

I am on the latest macOS.

What does it say if you try opam install domainslib.0.3.0? (this comes currently from the same opam remote you are getting the 4.12.0+domains+effects compiler from).

1 Like
opam install domainslib.0.3.0

The following actions will be performed:
  βˆ— install domainslib 0.3.0

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
[domainslib.0.3.0] found in cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
βˆ— installed domainslib.0.3.0
Done.

After that did opam update (which completed without problems) and opam upgrade -y reported that there’s nothing to do.