diff --git a/CHANGES.md b/CHANGES.md index bc128b90e..0b38fb9a7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,8 @@ package manager state (#322, @Leonidas-from-XIV) - Fix a bug where `pull` would crash if the lock file contained no package to vendor (#321, @NathanReb) +- Display a better error message when the depext command fails when getting the + status of the packages (#258, #323, @RyanGibb, @Julow) ### Removed diff --git a/cli/depext.ml b/cli/depext.ml index 52bbbc0b5..dc8c6b019 100644 --- a/cli/depext.ml +++ b/cli/depext.ml @@ -12,6 +12,11 @@ let should_install ~yes pkgs = pkgs) ~yes +let available_packages pkgs = + match OpamSysInteract.packages_status pkgs with + | available_pkgs, _not_found_pkgs -> Ok available_pkgs + | exception Failure msg -> Error (`Msg msg) + let run (`Root root) (`Lockfile explicit_lockfile) dry_run (`Yes yes) () = let open Result.O in let* lockfile = Common.find_lockfile ~explicit_lockfile root in @@ -26,11 +31,10 @@ let run (`Root root) (`Lockfile explicit_lockfile) dry_run (`Yes yes) () = else acc) ~init:OpamSysPkg.Set.empty depexts in - let pkgs, _ = OpamSysInteract.packages_status pkgs in - let pkgs_list = OpamSysPkg.Set.elements pkgs in - match pkgs_list with + let* pkgs = available_packages pkgs in + match OpamSysPkg.Set.elements pkgs with | [] -> Ok () - | _ -> + | pkgs_list -> let pkgs_str = List.map ~f:OpamSysPkg.to_string pkgs_list in if dry_run then ( Fmt.pr "%s\n%!" (String.concat ~sep:" " pkgs_str);