Skip to content

Commit

Permalink
Ensure OPAM_SWITCH_PREFIX is correctly set by opam env
Browse files Browse the repository at this point in the history
even if the files have been moved / the switch renamed.

This is not a complete fix to ocaml#3411 (doesn't add a warning, and the PATH
will only become correct once a package operation has been done), but
avoids the pathological cases.
  • Loading branch information
AltGr committed Jun 15, 2018
1 parent a36b335 commit f7671c1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/state/opamEnv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ let get_opam_raw ?(set_opamroot=false) ?(set_opamswitch=false) ~force_path
root switch =
let env_file = OpamPath.Switch.environment root switch in
let upd = OpamFile.Environment.safe_read env_file in
let upd =
("OPAM_SWITCH_PREFIX", Eq,
OpamFilename.Dir.to_string (OpamPath.Switch.root root switch),
Some "Prefix of the current opam switch") ::
List.filter (function ("OPAM_SWITCH_PREFIX", Eq, _, _) -> false | _ -> true)
upd
in
let upd =
if force_path then
List.map (function
Expand Down

0 comments on commit f7671c1

Please sign in to comment.