From 09dad6f9b02e6e3733f4003205716cae072a91ae Mon Sep 17 00:00:00 2001 From: Jonah Beckford <71855677+jonahbeckford@users.noreply.github.com> Date: Wed, 29 Nov 2023 19:50:32 -0800 Subject: [PATCH] bugfix: Add /usr/bin to PATH Only for precompiled binaries which are already in usr/bin. + Add tracing to autodetect compiler. +bugfix: Detect installation prefix now that precompiled are in usr/bin not bin/. Needs two directories up not one. Part of https://github.com/diskuv/dkml-installer-ocaml/issues/77 --- src/with-dkml/cmdline.ml | 10 ++++++---- src/with-dkml/with_dkml.ml | 9 ++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/with-dkml/cmdline.ml b/src/with-dkml/cmdline.ml index ffb2926..597c913 100644 --- a/src/with-dkml/cmdline.ml +++ b/src/with-dkml/cmdline.ml @@ -142,10 +142,10 @@ let when_path_exists_set_env ~envvar path = let set_precompiled_env abs_cmd_p = let ( let* ) = Rresult.R.( >>= ) in - (* Installation prefix *) - let prefix_p = Fpath.(parent (parent abs_cmd_p)) in + (* Installation prefix. Example: /usr/bin/utop -> *) + let prefix_p = Fpath.(abs_cmd_p |> parent |> parent |> parent) in let bc_p = Fpath.(prefix_p / "desktop" / "bc") in - let bc_bin_p = Fpath.(bc_p / "bin") in + let bc_usr_bin_p = Fpath.(bc_p / "usr" / "bin") in let bc_ocaml_lib_p = Fpath.(bc_p / "lib" / "ocaml") in let bc_ocaml_stublibs_p = Fpath.(bc_ocaml_lib_p / "stublibs") in let bc_stublibs_p = Fpath.(bc_p / "lib" / "stublibs") in @@ -187,7 +187,9 @@ let set_precompiled_env abs_cmd_p = in (* Dune requires ocamlc in the PATH. It should already be present but just in case put the bytecode executables in the PATH *) - let* () = when_dir_exists_prepend_pathlike_env ~envvar:"PATH" bc_bin_p in + let* () = + when_dir_exists_prepend_pathlike_env ~envvar:"PATH" bc_usr_bin_p + in Ok () | _ -> (* In an Opam switch diff --git a/src/with-dkml/with_dkml.ml b/src/with-dkml/with_dkml.ml index 63dccae..67201b1 100644 --- a/src/with-dkml/with_dkml.ml +++ b/src/with-dkml/with_dkml.ml @@ -286,7 +286,14 @@ let set_msvc_entries cache_keys = let dash = Fpath.(msys2_dir / "usr" / "bin" / "dash.exe" |> to_string) in - let cmd = Cmd.(v dash % Fpath.to_string tmp_sh_file) in + let extra_options = + match Logs.level () with + | Some Debug -> Cmd.(v "-x") + | _ -> Cmd.empty + in + let cmd = + Cmd.(v dash %% extra_options % Fpath.to_string tmp_sh_file) + in (OS.Cmd.run_status cmd >>= function | `Exited status -> if status <> 0 then