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

(alert deprecated): Core.Sys.is_directory [since 2021-04] Use [Sys_unix] #155

Open
mimoo opened this issue Aug 7, 2022 · 11 comments
Open
Labels
forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system.

Comments

@mimoo
Copy link

mimoo commented Aug 7, 2022

I'll write my investigation following this error message as a thread, perhaps it can serve as feedback for the user experience of using this library (or ocaml more generally)

I'm getting this error message

(alert deprecated): Core.Sys.is_directory
[since 2021-04] Use [Sys_unix]

the message seems weird, as it seems to imply to move to a function that will only work on unix systems.

anyway, I am on a unix system, so screw windows I guess. So I tried using Core.Sys_unix.is_directory but it doesn't seem to exist.

usually I would expect the error message to link me to more information, but no so I'm still digging.

@mimoo
Copy link
Author

mimoo commented Aug 7, 2022

On the Core documentation here https://ocaml.org/p/core/v0.15.0/doc/Core/Sys/index.html I can see that a lot of things are marked as Use_Sys_unix` but no indication seems to appear on what that is. I wish I could search the value Use_Sys_unix` in the documentation of Core but there doesn't seem to be a functionality to search in all the documentation

@mimoo
Copy link
Author

mimoo commented Aug 7, 2022

Looks like there is a package called Core_unix https://ocaml.org/u/fc567798a08fe03047f17d3fa542a580/core_unix/v0.15.0/doc/Sys_unix/index.html which seems to be related to Core. It's weird, I thought we only had Core and Base now, instead of Core/Base/Core_kernel, but there still seem to be a Core/Base/Core_unix? And tha module offers a Sys_unix https://ocaml.org/u/fc567798a08fe03047f17d3fa542a580/core_unix/v0.15.0/doc/Sys_unix/index.html so I guess that's what I should use

@mimoo
Copy link
Author

mimoo commented Aug 7, 2022

I look for the line to add to my opam file in the documentation, something like "core_unix" {>= "0.15.0"}, I can't find it. I guess I'll write it myself, but if I was starting with a blank opam file it would have been annoying

@mimoo
Copy link
Author

mimoo commented Aug 7, 2022

hum... so now I have two opens:

open Core
open Core_unix

I'm really wondering if this will be an issue, or if I should import one before the other, let's see...

@mimoo
Copy link
Author

mimoo commented Aug 7, 2022

now I'm getting:

9 |       let is_dir = Sys_unix.is_directory file in
                       ^^^^^^^^^^^^^^^^^^^^^
Error: Unbound module Sys_unix

how is this possible? Sys_unix is in the doc https://ocaml.org/p/core_unix/v0.15.0/doc/Sys_unix/index.html

@mimoo
Copy link
Author

mimoo commented Aug 7, 2022

maybe I don't have the right version of core_unix?

opam installed-libraries
opam: unknown command `installed-libraries'.
Usage: opam COMMAND ...
Try `opam --help' for more information.

urg...

opam list | grep core
core                        v0.15.0     Industrial strength alternative to OCaml's standard library
core_kernel                 v0.15.0     Industrial strength alternative to OCaml's standard library
core_unix                   v0.15.0     Unix-specific portions of Core

ok looks like I have the same version as the doc, what could it be?

@mimoo
Copy link
Author

mimoo commented Aug 7, 2022

OK, thanks to ocaml-lsp I manage to click on Core_unix and jump to the source. I see open! Core in the code, what is this ! after open? Stackoverflow has the answer fortunately https://stackoverflow.com/questions/22607755/what-does-open-mean

I still can't find any information there on a Sys_unix. I feel like giving up

@mimoo
Copy link
Author

mimoo commented Aug 7, 2022

ok let's try another path, google "sys_unix" ocaml. Nothing useful in the search result. Looking for "core_unix" ocaml I don't find anything useful as well. Well, I'll give up for today.

@mimoo
Copy link
Author

mimoo commented Aug 7, 2022

right before giving up, I think I vaguely remember that maybe importing core_unix.sys_unix in my dune file might work to import subpackages in an opam release. HOLE SHIT IT WORKED. Another "interesting" way in which opam and dune seem to interact

@github-iron github-iron added the forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system. label Oct 31, 2022
@shlomenu
Copy link

Just wanted to add that I encountered the same message, and was not able to access any library called sys_unix as installable through OPAM, or namespaced via Core or Core_unix. I encountered the issue upon upgrading to Core 15.1 from 14.2; my codebase had previously compiled while using functions from Core.Sys, and then I began receiving the same warning reported by @mimoo.

I was able to solve it simply by referencing Caml.Sys following open Core, as I noticed that this was how the source of the core_unix package seemed to be accessing a Sys-like module after its own open! Core statement.

I find the current tiers of Jane Street stdlib overlays to be quite confusing. I understand the motivation was to eliminate core_kernel. It looks like progress was made in this direction as Core v15 now includes its own Core.Core_kernel_stable module (I assume as a step towards deprecation of the independent core_kernel package). However, the independent core_kernel package still exists and is being upgraded, and even contains some data structures (such as Pairing_heap) whose implementations do not appear to be available through Core or Base (or Core_unix) and are depended upon by tests in their repositories. It seems that welcome improvements are afoot, but it is also a challenge to deal with opaque changes to such commonly referenced namespaces as Sys.

@rnollet
Copy link

rnollet commented Oct 25, 2024

Thanks for this thread. I had the same question.
Indeed, the READMEs in core_unix say that these are the old Core.Sys and Core.Unix :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system.
Projects
None yet
Development

No branches or pull requests

4 participants