diff --git a/bin/main.ml b/bin/main.ml index afc0ac98..29299108 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -70,7 +70,7 @@ let find_root () = if String_set.mem "jbuild-workspace" files then cont counter ~candidates:((0, dir, to_cwd) :: candidates) dir ~to_cwd else if String_set.exists files ~f:(fun fn -> - String.is_suffix fn ~suffix:".opam") then + String.is_suffix fn ~suffix:".opam" && fn <> ".opam") then cont counter ~candidates:((1, dir, to_cwd) :: candidates) dir ~to_cwd else if String_set.mem ".git" files || String_set.mem ".hg" files then cont counter ~candidates:((2, dir, to_cwd) :: candidates) dir ~to_cwd diff --git a/doc/manual.org b/doc/manual.org index 83cde82a..1f76690c 100644 --- a/doc/manual.org +++ b/doc/manual.org @@ -152,6 +152,9 @@ only declare parts of the packages in this subtree. Typically your =.opam= files should be at the root of your project, since this is where =opam pin ...= will look for them. +Note that == must be non empty, so in particular =.opam= +files are ignored. + *** Package version Note that Jbuilder will try to determine the version number of @@ -985,7 +988,7 @@ Jbuilder looks for the following entries in all these directories, in order of precedences: 1. =jbuild-workspace= -2. any file ending with =.opam= +2. any file ending with =.opam=, except =.opam= itself 3. =.git= or =.hg= The first entry to match in this list will determine the root. If this diff --git a/src/jbuild_load.ml b/src/jbuild_load.ml index 74280c6f..a019d11e 100644 --- a/src/jbuild_load.ml +++ b/src/jbuild_load.ml @@ -148,7 +148,7 @@ let load () = let path = File_tree.Dir.path dir in String_set.fold (File_tree.Dir.files dir) ~init:acc ~f:(fun fn acc -> match Filename.split_ext fn with - | Some (pkg, ".opam") -> + | Some (pkg, ".opam") when pkg <> "" -> let version_from_opam_file = let lines = lines_of_file (Path.relative path fn |> Path.to_string) in List.find_map lines ~f:(fun s ->