diff --git a/src/client/opamClient.ml b/src/client/opamClient.ml index efaddd6c533..9a8fc454b94 100644 --- a/src/client/opamClient.ml +++ b/src/client/opamClient.ml @@ -1054,7 +1054,7 @@ let rec cygwin_menu ~bypass_checks header = options, `Chosen (`Cygwin, `Internal), None | Some (Ok (kind, root)) -> let pacman = - OpamFilename.Op.(root / "usr" / "bin" // "pacman.exe") + OpamFilename.Op.(OpamSysInteract.Cygwin.bindir_for_root `Msys2 root // "pacman.exe") |> OpamFilename.to_string in let root = OpamFilename.Dir.to_string root in @@ -1219,11 +1219,12 @@ let string_of_git_location_cli = function | Right () -> "git-location disabled via CLI" let initialise_msys2 root = - let pacman = OpamFilename.Op.(root / "usr" / "bin" // "pacman.exe") in + let bindir = OpamSysInteract.Cygwin.bindir_for_root `Msys2 root in + let pacman = OpamFilename.Op.(bindir // "pacman.exe") in let gnupg_dir = OpamFilename.Op.(root / "etc" / "pacman.d" / "gnupg") in if OpamFilename.exists pacman && not (OpamFilename.exists_dir gnupg_dir) then let cmd = - OpamFilename.Op.(root / "usr" / "bin" // "bash.exe") + OpamFilename.Op.(bindir // "bash.exe") |> OpamFilename.to_string in let answer = @@ -1460,12 +1461,7 @@ let determine_windows_configuration ?cygwin_setup ?git_location in apply cygcheck, None | `Root root -> - let bindir = - if kind = `Msys2 then - root / "usr" / "bin" - else - root / "bin" - in + let bindir = OpamSysInteract.Cygwin.bindir_for_root kind root in (* If the user has specified --no-git-location and Git for Windows was in PATH and the given location occludes it, then this is our last chance to warn about it. *) diff --git a/src/state/opamSysInteract.ml b/src/state/opamSysInteract.ml index b506174f908..c14b8f1eb26 100644 --- a/src/state/opamSysInteract.ml +++ b/src/state/opamSysInteract.ml @@ -447,6 +447,12 @@ module Cygwin = struct in Result.bind cygbin identify + let bindir_for_root kind root = + let open OpamFilename.Op in + match kind with + | `Msys2 -> root / "usr" / "bin" + | `Cygwin -> root / "bin" + (* Set setup.exe in the good place, ie in .opam/.cygwin/ *) let check_setup ~update = let dst = cygsetup () in diff --git a/src/state/opamSysInteract.mli b/src/state/opamSysInteract.mli index c8bdd34d4ba..9254c9a00f6 100644 --- a/src/state/opamSysInteract.mli +++ b/src/state/opamSysInteract.mli @@ -66,6 +66,11 @@ module Cygwin : sig val analyse_install: string -> ([ `Cygwin | `Msys2 ] * OpamFilename.Dir.t, string) result + (* [bindir_for_root kind root] returns the bin directory for the given + installation root and [kind], as returned by {!analyse_install}. *) + val bindir_for_root: + [ `Cygwin | `Msys2 ] -> OpamFilename.Dir.t -> OpamFilename.Dir.t + (* Returns true if Cygwin install is internal *) val is_internal: OpamFile.Config.t -> bool