Skip to content
Browse files

Ignore OPAMSWITCH when displaying environment varilables (eg. on 'opa…

…m config env' or 'opam switch foo').

This fixes a regression introduced by 27b2f81 where you cannot switch anymore when you have OPAMSWITCH set.
  • Loading branch information...
1 parent b9c9f25 commit 13fad278e657b44bd0fe05f97899e0cc2b24af9e @samoht committed Mar 27, 2013
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/client/opamState.ml
View
11 src/client/opamState.ml
@@ -900,10 +900,7 @@ let env_updates t =
let man_path =
"MANPATH", ":=", OpamFilename.Dir.to_string (OpamPath.Switch.man_dir t.root t.switch) in
let comp_env = OpamFile.Comp.env comp in
- let switch =
- match !OpamGlobals.switch with
- | None -> []
- | Some s -> [ "OPAMSWITCH", "=", s ] in
+ let switch = [ "OPAMSWITCH", "=", OpamSwitch.to_string t.switch ] in
let root =
if !OpamGlobals.root_dir <> OpamGlobals.default_opam_dir then
[ "OPAMROOT", "=", !OpamGlobals.root_dir ]
@@ -912,7 +909,13 @@ let env_updates t =
new_path :: man_path :: toplevel_dir :: (switch @ root @ comp_env)
+(* This function is used by 'opam config env' and 'opam switch' to
+ display the environment variables. We have to make sure that
+ OPAMSWITCH is always the one being reported in '~/.opa/config'
+ otherwise we can have very weird results (as the inability to switch
+ between compilers). *)
let get_opam_env t =
+ let t = { t with switch = OpamFile.Config.switch t.config } in
add_to_env t [] (env_updates t)
let get_full_env t =

0 comments on commit 13fad27

Please sign in to comment.
Something went wrong with that request. Please try again.