Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add OPAMROOT environment variable.

This enables:
* 'opam --root $dir config -env' to output the right $OPAMROOT variable;
* which means subsequents calls to 'opam' will use the right root path.

This help installing opam on multi-user computers (where root is set to /usr/lib/opam for instance).

This should fix #302
  • Loading branch information...
commit c57e9b0a69712147f551d76b71465afd21074cef 1 parent b83a005
@samoht samoht authored
View
2  src/client/opamMain.ml
@@ -28,8 +28,6 @@ let bad_argument cmd fmt =
let noanon cmd s =
raise (Bad (cmd, s ^ " is not expected"))
-let () = OpamGlobals.root_dir := OpamGlobals.default_opam_dir
-
(* Useful for switch, which can overwrite the default verbose flag *)
let quiet = ref false
View
7 src/client/opamState.ml
@@ -552,6 +552,13 @@ let get_env t =
let add_to_env = expand_env t add_to_env in
let new_env = expand_env t new_env in
+ (* if --root <dir> is passed on the command line, or if OPAMROOT is set. *)
+ let new_env =
+ if !OpamGlobals.root_dir <> OpamGlobals.default_opam_dir then
+ ("OPAMROOT", !OpamGlobals.root_dir) :: new_env
+ else
+ new_env in
+
{ add_to_env; add_to_path; new_env }
let print_env_warning ?(add_profile = false) t =
View
12 src/core/opamGlobals.ml
@@ -42,12 +42,16 @@ let switch : string option ref = ref None
let opam_version = "1"
let home =
- try Unix.getenv "HOME"
- with _ -> Unix.getcwd ()
+ try Sys.getenv "HOME"
+ with _ -> Sys.getcwd ()
-let default_opam_dir = Filename.concat home ".opam"
+let default_opam_dir =
+ Filename.concat home ".opam"
-let root_dir = ref default_opam_dir
+let root_dir = ref (
+ try Sys.getenv "OPAMROOT"
+ with _ -> default_opam_dir
+)
let log section fmt =
Printf.ksprintf (fun str ->
Please sign in to comment.
Something went wrong with that request. Please try again.