Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opam should scrub 2.1-specific environment variables in the build #4660

Closed
dra27 opened this issue May 14, 2021 · 0 comments · Fixed by #4663
Closed

opam should scrub 2.1-specific environment variables in the build #4660

dra27 opened this issue May 14, 2021 · 0 comments · Fixed by #4663
Milestone

Comments

@dra27
Copy link
Member

dra27 commented May 14, 2021

opam 2.1 sets OPAMCLI=2.0 for package builds (#4492). If the user has set an opam 2.1-specific variable in the environment then this leaks to the package build and causes a warning for any calls to opam itself within the package's build instructions.

We should scrub environment variables (with a note to the debugging log) which aren't available in the 2.0 CLI.

The build environment for a package is constructed here:

let compilation_env t opam =
let open OpamParserTypes in
OpamEnv.get_full ~force_path:true t ~updates:([
"CDPATH", Eq, "", Some "shell env sanitization";
"MAKEFLAGS", Eq, "", Some "make env sanitization";
"MAKELEVEL", Eq, "", Some "make env sanitization";
"OPAM_PACKAGE_NAME", Eq,
OpamPackage.Name.to_string (OpamFile.OPAM.name opam),
Some "build environment definition";
"OPAM_PACKAGE_VERSION", Eq,
OpamPackage.Version.to_string (OpamFile.OPAM.version opam),
Some "build environment definition";
"OPAMCLI", Eq, "2.0", Some "opam CLI version";
] @
OpamFile.OPAM.build_env opam)

and here:

opam/src/state/opamEnv.ml

Lines 225 to 236 in a70ed4f

let updates_common ~set_opamroot ~set_opamswitch root switch =
let root =
if set_opamroot then
[ "OPAMROOT", Eq, OpamFilename.Dir.to_string root,
Some "Opam root in use" ]
else []
in
let switch =
if set_opamswitch then
[ "OPAMSWITCH", Eq, OpamSwitch.to_string switch, None ]
else [] in
root @ switch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant