ocamlocaml-core

How to deal with the error: Unbound module Sys_unix


I've encountered the error Unbound module Sys_unix`.

The code in utop is:

utop # #require "core_unix";;
utop # open Core;;
utop # open Core_unix;;
utop # open Sys;;
utop # open Core_unix.Sys_unix;;
Error: Unbound module Core_unix.Sys_unix
utop # Sys.readdir "/Users/";;
Line 1, characters 0-11:
Alert deprecated: Core.Sys.readdir
[since 2021-04] Use [Sys_unix]
Line 1, characters 0-11:
Alert deprecated: Core.Sys.readdir
[since 2021-04] Use [Sys_unix]
- : [ `Use_Sys_unix ] = `Use_Sys_unix
utop # Sys_unix.readdir;;
Error: Unbound module Sys_unix

I don't know why and I can't even find a documentation about module Sys_unix.


Solution

  • Here's the documentation: https://ocaml.org/p/core_unix/v0.15.0/doc/Sys_unix/index.html

    The module seems to be in the library core_unix.sys_unix, which is in the package core_unix.

    I would expect this to work, assuming you have installed the package:

    #require "core_unix.sys_unix";;
    open Sys_unix;;