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

[dune engine] [bug] Error file unavaiable when an absolute path points to a symlink. #5833

Open
ejgallego opened this issue Jun 5, 2022 · 18 comments

Comments

@ejgallego
Copy link
Collaborator

ejgallego commented Jun 5, 2022

Dune seems to error when dune build $file is called with $file being an absolute path towards a symlink.

Example with a trivial project that builds library foo:

$ dune clean
$ dune build /home/egallego/tmp/dune-bugs/ext/_build/install/default/lib/bar/META
Error: File unavailable:
/home/egallego/tmp/dune-bugs/ext/_build/install/default/lib/bar/META
$ dune build _build/install/default/lib/bar/META
$ # Success, now the first command also works

This is where the error is raised:

| No_such_file -> report_user_error []

This seems like a bug in Dune. If the dep on the external file is not allowed, Dune should error at Action_build.dyn_deps.

Note that the missing file is a symlink for the error to be produced.

Likely test case to reproduce:

  • setup a rule using Action_builder.dyn_paths that depends on something that is a symlink and uses an absolute path.

note: I have cleaned up this issue as the discussion was quite confusing due to some users hitting this bug + a Coq bug. The Coq bug is unrealted, this seems like a pure dune issue.

@ejgallego

This comment was marked as resolved.

@ejgallego
Copy link
Collaborator Author

Note the file coqdep produces is an absolute path (that could be the point is confusing dune)

Ali mentioned that the problem could be related to the cache, that was my impression too, but I'm not sure.

@Alizter
Copy link
Collaborator

Alizter commented Jun 6, 2022

Windows builds and cache enabled seems to trigger it.

@ejgallego
Copy link
Collaborator Author

It can be triggered reliably c.f. coq/coq#15608

@Alizter Alizter moved this to Todo in Coq + Dune Jun 6, 2022
@Alizter Alizter moved this from Todo to Planned for Coq lang 1.0 in Coq + Dune Jun 6, 2022
@Alizter Alizter added the coq label Jun 6, 2022
@ejgallego
Copy link
Collaborator Author

We found more info on this, updating the issue.

corwin-of-amber added a commit to jscoq/addon-elpi that referenced this issue Sep 3, 2022
corwin-of-amber added a commit to jscoq/addon-equations that referenced this issue Sep 3, 2022
corwin-of-amber added a commit to jscoq/addon-elpi that referenced this issue Sep 3, 2022
@Alizter Alizter moved this from Planned for Coq lang 1.0 to Todo in Coq + Dune Oct 9, 2022
@rlepigre
Copy link
Contributor

I'm experiencing a similar problem, also in the context of a Coq project with plugins. Has anyone understood the problem yet? Is there a workaround?

@Alizter
Copy link
Collaborator

Alizter commented Oct 13, 2022

@rlepigre The issue for plugins should be fixed: #6167. It will be included in Dune 3.5 which is set to release soon.

@ejgallego

This comment was marked as resolved.

@ejgallego

This comment was marked as resolved.

@rlepigre
Copy link
Contributor

rlepigre commented Oct 13, 2022

What is your Declare ML Module ?

I have several plugins, and hence several Declare ML Module. They are all placed in the same opam package. So for each plugin my dune file looks something like this:

(library
 (name my_plugin)
 (public_name my_plugins.my_plugin))

And the corresponding declaration in a Coq file is:

Declare ML Module "my_plugin:my_plugins.my_plugin".

@ejgallego
Copy link
Collaborator Author

That's on 8.16 , right? What's the name of the META file that coqdep generates?

I'm afraid that we may want to patch coqdep so in legacy mode the meta file dep is not emitted. See declare_ml_to_file in tools/coqdep/lib/common.ml

@rlepigre
Copy link
Contributor

rlepigre commented Oct 13, 2022

Yes, on Coq 8.16.0. I'm not sure what the name of the generated META file is. How do I figure that out? I expected I could just look in the file.v.d file corresponding to the file.v file that has the Declare ML Module, but I see no META file.

ejgallego added a commit to ejgallego/coq that referenced this issue Oct 13, 2022
If the legacy mode is set, we don't even attempt to use findlib to
resolve anything, we also won't emit a META dependency, even if this
dependency is in scope.

This is morally the right thing to do, should reduce non-determinism,
and helps a bit to isolate the legacy code more.

This should help with problems such as
ocaml/dune#5833
@ejgallego
Copy link
Collaborator Author

I mean, what is the name of the file that dune crashes on?

But indeed I think we should write a patch for Coq 8.16.1 , see coq/coq#16658

@ejgallego
Copy link
Collaborator Author

@rlepigre let me know if that PR fixes the problem for you.

@rlepigre
Copy link
Contributor

Oh sorry. The error I get is something like:

Error: File unavailable:
/absolute/path/to/_build/install/default/lib/my_plugins/META

I'll try out the MR later and let you know. Thanks!

@ejgallego
Copy link
Collaborator Author

I see thanks, my PR should fix that for now, hopefully. The Dune bug should also be fixed of course.

rlepigre added a commit to rlepigre/coq that referenced this issue Oct 14, 2022
If the legacy mode is set, we don't even attempt to use findlib to
resolve anything, we also won't emit a META dependency, even if this
dependency is in scope.

This is morally the right thing to do, should reduce non-determinism,
and helps a bit to isolate the legacy code more.

This should help with problems such as
ocaml/dune#5833

Co-authored-by: Emilio Jesús Gallego Arias <e@x80.org>
rlepigre added a commit to rlepigre/coq that referenced this issue Oct 14, 2022
[coqdep] Be more deterministic w.r.t. the plugin loading mode

If the legacy mode is set, we don't even attempt to use findlib to
resolve anything, we also won't emit a META dependency, even if this
dependency is in scope.

This is morally the right thing to do, should reduce non-determinism,
and helps a bit to isolate the legacy code more.

This should help with problems such as
ocaml/dune#5833

Co-authored-by: Emilio Jesús Gallego Arias <e@x80.org>
rlepigre added a commit to rlepigre/coq that referenced this issue Oct 14, 2022
[coqdep] Be more deterministic w.r.t. the plugin loading mode

If the legacy mode is set, we don't even attempt to use findlib to
resolve anything, we also won't emit a META dependency, even if this
dependency is in scope.

This is morally the right thing to do, should reduce non-determinism,
and helps a bit to isolate the legacy code more.

This should help with problems such as
ocaml/dune#5833

Co-authored-by: Emilio Jesús Gallego Arias <e@x80.org>
@rlepigre
Copy link
Contributor

rlepigre commented Oct 14, 2022

@ejgallego I confirmed that your patch to Coq (or rather, my back-ported version of it) fixes my problem. Thanks!
For reference, see coq/coq#16664.

@ejgallego
Copy link
Collaborator Author

Glad to hear @rlepigre ; actually there is not a lot that we need to support the new findlib loading mode in Dune, main road block is coq/coq#16571 but that should be not too hard to fix when we get a minute.

Blaisorblade pushed a commit to Blaisorblade/coq that referenced this issue Jan 7, 2023
If the legacy mode is set, we don't even attempt to use findlib to
resolve anything, we also won't emit a META dependency, even if this
dependency is in scope.

This is morally the right thing to do, should reduce non-determinism,
and helps a bit to isolate the legacy code more.

This should help with problems such as
ocaml/dune#5833

Co-authored-by: Emilio Jesús Gallego Arias <e@x80.org>
@ejgallego ejgallego removed the coq label Feb 20, 2023
@ejgallego ejgallego changed the title Error: file not available when depending on an external dep [dune engine] [bug] Error file unavaiable when an absolute path points to a symlink. Feb 20, 2023
@Alizter Alizter added the bug label Mar 11, 2023
@Alizter Alizter added the coq label Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

3 participants