-
Notifications
You must be signed in to change notification settings - Fork 14
Remove /opt/homebrew mentions from PATH #66
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -680,6 +680,16 @@ def compile(self): | |
| runez.decompress(path, self.m_src_build, simplify=True) | ||
|
|
||
| env_vars = self._get_env_vars() | ||
| if not PPG.config.get_value("allow-homebrew"): | ||
| # Remove any mention of /opt/homebrew from PATH (reduce chances of dynamic links to homebrew) | ||
| path_env_var = env_vars.get("PATH") | ||
| if path_env_var: | ||
| _paths = os.environ.get("PATH", "").split(":") | ||
| _revised = [p for p in _paths if not p.startswith("/opt/homebrew")] | ||
| if _revised != _paths: | ||
| LOG.info("Removed /opt/homebrew mentions from PATH") | ||
| env_vars["PATH"] = runez.joined(_revised, delimiter=":") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Env vars are in effect just for this |
||
|
|
||
| prev_env_vars = {} | ||
| for var_name, value in env_vars.items(): | ||
| LOG.info("env %s=%s", var_name, runez.short(value, size=2048)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is gated by the presence of configured env_vars but mutates the
os.environmentvars. Shouldn't this:a. be done regardless of configured env vars
b. take into account the configured paths instead of wholesale overriding them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mechanism used takes into account existing env vars, configured env vars, and programmatically yielded env vars. The idea was to do similarly to how most build scripts are written, typically like
"CFLAGS=${CFLAGS} -Lmy-flag".One can always do this to just set an env var to something (without following this "additive" behavior that p-p has):
But you're right I could do this at startup actually 🤔
b) is already the case (p-p follows the same "additive" approach for all env vars)
a) -> yup, I could indeed "groom" PATH at startup instead of here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only diff in doing it here vs at startup, is that here any modification of PATH gets restored... whereas if done on startup, it would stick throughout the whole p-p run.
This place here is called by the
compile()function, so we'll get like:openssl.compile()-> that would groom PATH then restore itcpython.compile()-> same thingUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think it's best if we do it like this here, it does allow for an "advanced" case like for example this config:
Now, homebrew is allowed on macos AND for openssl only (every other component will have
/opt/homebrewcleaned up from PATH by default).One could also decide to allow homebrew globally, with like at top-level: