-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Ensure TMPDIR is set for Xcode’s make
#7283
Conversation
To copy what I said over Slack: if there is a particular reason that |
I would prefer this method is taken. Seems nicer to use the value if set by users. |
@MikeMcQuaid You mean we should leave |
As in: I think we shouldn't whitelist the value but instead unconditionally set it to |
make
@MikeMcQuaid Done, thanks for your feedback!
@Bo98 I’m quite confident Homebrew doesn’t rely on |
This is already set for formula builds: As a result, what about instead just setting it where it's needed e.g. for gems: |
On the fence about that. On macOS, removing But that’s just me speculating. So let’s set it in gems.rb, and revisit/reconsider in case the issue pops up again. |
This fixes an issue where at least in Xcode 11.0, `make` uses `/var/tmp` as a fallback for temporary files unless `TMPDIR` is set: ``` $ strings "$(xcrun -f make)" | grep -B 3 fopen TMPDIR /var/tmp/ GmXXXXXX fopen (temporary file) ``` Given that Homebrew filtered `TMPDIR`, and the `/var/tmp` directory may not be writable for non-root users, this would cause Homebrew’s build environment to error out: ``` $ brew ruby -e 'puts ENV["TMPDIR"]; puts `: | make -f -`' ``` ``` Ignoring bigdecimal-2.0.0 because its extensions are not built. Try: gem pristine bigdecimal --version 2.0.0 […] Ignoring zlib-1.1.0 because its extensions are not built. Try: gem pristine zlib --version 1.1.0 make: *** fopen (temporary file): Permission denied. Stop. ``` In practice, this would break `brew audit`, `brew style`, and other commands, which would run `make` to build native gem extensions. This commit sets `TMPDIR` to `${HOMEBREW_TEMP}` in the gem environment, which mirrors the behaviour we already have in other places. We choose `HOMEBREW_TEMP` because that’s user-controlled but also falls back to `/tmp` in case `TMPDIR` is not set in the user’s environment. Thanks to Bo Anderson for helping find the bug. CC: Bo Anderson <mail@boanderson.me>
@MikeMcQuaid @Bo98 Updated. |
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.
Thanks @claui!
Edit: changed title and final paragraph to reflect new modifications. Also changed embarrassing grammar in thank-you notice.
Edit 2: changed final paragraph to reflect that the code has been moved to
gems.rb
./var/tmp
may or may not be writable on a machine that runs the tests.brew style
with your changes locally? Yes, and it worked for the first time in agesbrew tests
with your changes locally?Not applicableEdit: yes but--only=utils
.This fixes an issue where at least in Xcode 11.0,
make
uses/var/tmp
as a fallback for temporary files unlessTMPDIR
is set:Given that Homebrew filtered
TMPDIR
, and the/var/tmp
directory may not be writable for non-root
users, this would cause Homebrew’s build environment to error out:$ brew ruby -e 'puts ENV["TMPDIR"]; puts `: | make -f -`'
In practice, this would break
brew audit
,brew style
, and othercommands, which would run
make
to build native gem extensions.This commit addsTMPDIR
to Homebrew’s list of allowed environmentvariables. It also adds unconditionally sets
TMPDIR
to${HOMEBREW_TEMP}
, whichis user-controlled but also guaranteed to be set with a fallback of
/tmp
, which takes precedenceover
/var/tmp
in caseTMPDIR
is not set in the user’s environment.This commit sets
TMPDIR
to${HOMEBREW_TEMP}
in the gem environment, which mirrors the behaviour we already have in other places.We choose
HOMEBREW_TEMP
because that’s user-controlled but also falls back to/tmp
in caseTMPDIR
is not set in the user’s environment.Thanks to Bo Anderson for helping find the bug.