From 637177eed753b33e3f162cf16c1068158a81b85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20Roch=C3=A9=20=28Ahrefs=29?= Date: Tue, 25 Jan 2022 22:27:29 +0800 Subject: [PATCH] Fix opam root dir detection when no switch is set --- CHANGES.md | 2 ++ src/opam.ml | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index c7ecbe92b..77d95208a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Fix the detection of opam's root directory when no switch is detected (#831) + - Warn if the extension sees not the latest OCaml-LSP version compatible with the OCaml distribution installed in the current sandbox. diff --git a/src/opam.ml b/src/opam.ml index c3d45a014..7e0757ace 100644 --- a/src/opam.ml +++ b/src/opam.ml @@ -20,7 +20,9 @@ let make ?root () = | Error _, _ -> Promise.return None | Ok bin, Some root -> Promise.return (Some { bin; root }) | Ok bin, None -> ( - let var_root_cmd = Cmd.Spawn (Cmd.append bin [ "var"; "root" ]) in + let var_root_cmd = + Cmd.Spawn (Cmd.append bin [ "var"; "--global"; "root" ]) + in let+ var_root_output = Cmd.output var_root_cmd in match var_root_output with | Error _ -> None