-
Notifications
You must be signed in to change notification settings - Fork 409
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
dune fmt
requires ocamlc
to be in path but does not guarantee that this is the case
#11038
Comments
It appears that dune always picks an ocaml toolchain when it starts, and part of that involves running One option would be use the ocaml toolchain implied by the ocamlformat lockdir. The problem with this is we'd like it to work when running Another option is to make dune invoke The third option is to make it so that running |
This is a workaround for an issue where dune needs to locate an ocaml toolchain in order to run `dune fmt`, and in the absence of a lockdir dune will look in PATH for ocaml tools, which may not be present. The consequence of this issue is that users of the developer preview can have an ocaml toolchain installed by dune (in their ~/.cache/dune/toolchains directory), and running `dune fmt` will complain about `ocamlc` not being found. Forcing the lockdir to exist means that dune will always take the toolchain implied by the lockdir, and there won't be a situation where the command fails due to `ocamlc` being missing. More info in this issue: ocaml#11038 Signed-off-by: Stephen Sherratt <[email protected]>
What does Dune do with From reading your investigation it seems that it is calling @rgrinberg what do you think is the right way to do here? |
I'll start working on deferring running |
I think I deferred running |
It looks like it's forced while setting up the rules of the project (which if I'm not mistaken happens on every |
Here's another idea. type t =
{ has_native : bool
; ext_lib : Filename.Extension.t
; ext_obj : Filename.Extension.t
; os_type : Ocaml_config.Os_type.t
; architecture : string
; system : string
; model : string
; natdynlink_supported : Dynlink_supported.By_the_os.t
; ext_dll : string
; stdlib_dir : Path.t
; ccomp_type : Ocaml_config.Ccomp_type.t
; ocaml_version_string : string
; ocaml_version : Ocaml.Version.t
} Some of these fields are facts about the system, and other fields are facts about the ocaml compiler. We use For the facts about the ocaml compiler, it's possible that they're not needed at all by |
That would break cross compilation.
Because we don't support cross compilation for package management
I hope that ends up being the case. Would be rather weird if the format rules had a direct dependency on the OCaml compiler. |
Ah I hadn't considered cross compilation. @rgrinberg what do you think about my previous comment about |
Seems like it should be possible to drop completely from Lib.DB.t |
Running
dune fmt
with the dev tools feature enabled (e.g. in the developer preview) dune will install ocamlformat before using it to format the project. However, dune also runsocamlc
to get information about the current system. Ifocamlc
isn't already in PATH when runningdune fmt
, and no lockdir is present, the command will fail with:Instead, this command should make sure that an ocaml compiler is installed via dune toolchains and add it to the environment in the appropriate place.
Note that this only happens when no lockdir is present because the presence of a lockdir changes how dune finds the ocaml compiler. As a workaround we can require that a lockdir exists when running
dune fmt
.The text was updated successfully, but these errors were encountered: