Skip to content

Commit

Permalink
Merge pull request #574 from diml/workaround-broken-builtins
Browse files Browse the repository at this point in the history
Add a simple workaround for #563
  • Loading branch information
rgrinberg committed Mar 5, 2018
2 parents 2945569 + d1feb06 commit 09aa2cd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ next

- Ignore errors during the generation of the .merlin (#569, fixes #568 and #51)

- Add a workaround for when a library normally installed by the
compiler is not installed but still has a META file (#574, fixes
#563)

1.0+beta18 (25/02/2018)
-----------------------

Expand Down
29 changes: 23 additions & 6 deletions src/findlib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,10 @@ let parse_package t ~meta_file ~name ~parent_dir ~vars =
Path.relative t.stdlib_dir
(String.sub pkg_dir ~pos:1 ~len:(String.length pkg_dir - 1))
else if Filename.is_relative pkg_dir then
Path.relative parent_dir pkg_dir
Path.relative parent_dir pkg_dir
else
Path.absolute pkg_dir
in
let exists_if = Vars.get_words vars "exists_if" Ps.empty in
let exists =
List.for_all exists_if ~f:(fun fn ->
Path.exists (Path.relative dir fn))
in
let pkg =
{ Package.
meta_file
Expand All @@ -206,6 +201,28 @@ let parse_package t ~meta_file ~name ~parent_dir ~vars =
; vars
}
in
let exists_if = Vars.get_words vars "exists_if" Ps.empty in
let exists =
match exists_if with
| _ :: _ ->
List.for_all exists_if ~f:(fun fn ->
Path.exists (Path.relative dir fn))
| [] ->
if not (String_map.mem t.builtins (root_package_name name)) then
true
else
(* The META files for installed packages are sometimes broken,
i.e. META files for libraries that were not installed by
the compiler are still present:
https://github.com/ocaml/dune/issues/563
To workaround this problem, for builtin packages we check
that at least one of the archive is present. *)
match Package.archives pkg with
| { byte = []; native = [] } -> true
| { byte; native } -> List.exists (byte @ native) ~f:Path.exists
in
let res =
if exists then
Ok pkg
Expand Down

0 comments on commit 09aa2cd

Please sign in to comment.