Closed silene closed 2 years ago
IMO this is an annoying enough problem to delay a bit the release of Coq 8.16.0.
I've seen this bug too, but I'm not so sure the fix is OK. The line of code you point to predates findlib: https://github.com/coq/coq/blame/master/sysinit/coqargs.ml#L451
I think it's rather the way we initialize findlib which is incorrect
https://github.com/coq/coq/blob/7f2e4bfc0ec0e2e6ff24a91e9060933e06c31d46/sysinit/coqinit.ml#L148-L156
If we do -I A -I B
ml_load_path is ["A";"B"]
(the system load paths are like having some extra -I at the beginning, later -I should have priority)
The List.iter (for legacy loading and Drop) is in the correct order, but for the OCAMLPATH env variable we produce $OCAMLPATH:A:B
where we should produce B:A:$OCAMLPATH
as it wants the highest priority at the beginning.
I'll try a PR.
We want A:B:$OCAMLPATH
, since the de facto standard in the compiler world is to parse -I
options left-to-right.
When loading a plugin, Coq/Findlib first looks in the system directories and then in the directories specified by option
-I
on the command line. As a consequence, if a plugin with the same name (e.g., an older version) happens to be installed in a system directory, Coq will load it instead of the one explicitly specified on the command line.This makes plugin development especially cumbersome. Indeed, one has to first remove any other installed version of the plugin (e.g.,
opam remove
). Otherwise, Coq will silently load an outdated version of the plugin.I think that replacing
ml_path @ opts.pre.ml_includes
byopts.pre.ml_includes @ ml_path
inCoqargs.build_load_path
is sufficient to fix this bug, but I have yet to test it. (This also begs the question of whethervo_path @ opts.pre.vo_includes
on the following line suffers from a similar bug.)Since it involves the Findlib machinery, this bug only exists in Coq 8.16 for now.