diff --git a/master_changes.md b/master_changes.md index 5dad46f64cc..53af43ebbaf 100644 --- a/master_changes.md +++ b/master_changes.md @@ -133,6 +133,7 @@ users) # API updates ## opam-client * `OpamClient.windows_checks`: On existing cygwin install, permit to detect msys2 and store `os-distribution=msys2` in `global-variables` config file field [#5843 @rjbou] + * `OpamClient.windows_checks`: When updating config file for msys2, resolve `pacman` path and store it in `sys-pkg-manager-cmd` for msys2 [#5843 @rjbou] ## opam-repository diff --git a/src/client/opamClient.ml b/src/client/opamClient.ml index 85682f7dcb0..835e57f00c6 100644 --- a/src/client/opamClient.ml +++ b/src/client/opamClient.ml @@ -813,7 +813,24 @@ let windows_checks ?cygwin_setup ?git_location config = OpamStd.Sys.exit_because `Aborted in let config = - if is_msys2 cygcheck then config else + if is_msys2 cygcheck then + let env = + OpamStd.Env.cyg_env ~cygbin:(OpamFilename.Dir.to_string cygbin) + ~git_location:None + in + match OpamSystem.resolve_command ~env "pacman.exe" with + | Some pacman -> + if OpamConsole.confirm + "Found package manager pacman binary at %s.\n\ + Do you want to use it for depexts?" + pacman then + OpamFile.Config.with_sys_pkg_manager_cmd + (OpamStd.String.Map.add distrib (OpamFilename.of_string pacman) + (OpamFile.Config.sys_pkg_manager_cmd config)) + config + else config + | None -> config + else OpamFile.Config.with_sys_pkg_manager_cmd (OpamStd.String.Map.add distrib cygcheck (OpamFile.Config.sys_pkg_manager_cmd config))