Skip to content

Commit 58f0afb

Browse files
committed
Make plugin resilient to sandbox building in opam
1 parent ad3b911 commit 58f0afb

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lib/coq_verified_extraction_plugin/lib/verified_extraction.ml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ let run_command opts cmd =
371371
let opam_command cmd =
372372
match get_opam_path_opt () with
373373
| Some s -> s ^ " exec -- " ^ cmd
374-
| None -> "opam exec -- " ^ cmd
374+
| None -> cmd
375375

376376
let execute opts cmd =
377377
let status, out, err = execute cmd in
@@ -706,12 +706,17 @@ let decompose_argument env sigma c =
706706

707707
let set_opam_env opts =
708708
let path = Unix.getenv "PATH" in
709-
let opam_path =
710-
match get_opam_path_opt () with
711-
| Some s -> s
712-
| None -> run_command opts "which opam"
709+
let opam_binpath =
710+
match Unix.getenv "OPAM_SWITCH_PREFIX" with
711+
| exception Not_found ->
712+
let opam_path =
713+
match get_opam_path_opt () with
714+
| Some s -> s
715+
| None -> run_command opts "which opam"
716+
in
717+
run_command opts (opam_path ^ " var --safe bin")
718+
| pref -> pref ^ "/bin"
713719
in
714-
let opam_binpath = run_command opts (opam_path ^ " var --safe bin") in
715720
Unix.putenv "PATH" (opam_binpath ^ ":" ^ path)
716721

717722
let extract_and_run

0 commit comments

Comments
 (0)