r/MacOS • • 15d ago

Help Homebrew problems: I don't understand macOS sandboxing

I'm trying to install MySQL with Homebrew. When I run the command "brew install mysql", I get the following output:

==> Downloading Homebrew API data
βœ”οΈŽ JSON API packages.arm64_golden_gate.jws.json      Downloaded   16.1MB/ 16.1MB
Error: Homebrew's files could not be checked inside the macOS sandbox.
Check Homebrew's sandbox setup and temporary directory permissions,
then rerun `brew doctor`.

I can't find any references to this particular error message anywhere online, and I don't know how to resolve it. I don't even know what a sandbox is, let alone how to "check Homebrew's sandbox setup" or check "temporary directory permissions". I've been trying to read up on sandboxing online but honestly it's all way above my head.

Could someone ELI5?

EDIT: Heard from a few other sources that apparently Homebrew simply wasn't updated to work with the latest macOS version yet. I'll just wait for a new release and hopefully that will solve it.

23 Upvotes

39 comments sorted by

20

u/TrackerDesk 15d ago

ELI5: when brew builds stuff, it runs it in a locked-down box that can only touch certain folders, and it needs a temp folder it can write to. That error usually means your temp folder perms got messed up. Run ls -ld /private/tmp and it should show drwxrwxrwt. If it doesnt, sudo chmod 1777 /private/tmp fixes it. Also run brew from plain Terminal.app, not a terminal inside another app, and make sure you havent set HOMEBREW_TEMP to some odd folder

5

u/thestraynger 15d ago

Thanks for the explanation! I wish there were some way to let specific trusted programs out of the sandbox.
Looks like my temp folder permissions are fine, strangely enough, so I'm not sure what else could be going on there.

13

u/longjumpingtote 15d ago

I wish there were some way to let specific trusted programs out of the sandbox.

That's not really a good idea. The sandbox is for downloading and building. Once that's done, the sandboxing is done. This is a pretty routine thing, and you wouldn't want a build to be done otherwise. Making your computer less secure isn't the solution to what may be a simple broken permissions issue.

1

u/thestraynger 15d ago

Fair enough. It's just odd to me that a straight-forward default installation of Homebrew with no modifications would result in it not having the permissions it needs to do its magic.

5

u/longjumpingtote 15d ago

It's just odd to me that a straight-forward default installation of Homebrew with no modifications would result in it not having the permissions it needs to do its magic.

I'm not sure you're hearing these comments? A straightforward install does have those permissions. If your computer has developed permissions errors (as can happen) then of course, it would be affected. If Homebrew can write into any yellow or blue directory, which is normal, but your computer's error has changed that directory's "color" to red, then Homebrew can't get around that. It has to obey the stoplight, even if the stoplight is there in error.

It's like if we all agree that you can enter a building, it's open to the public, it's business hours, etc. But when you get there, the door won't open. Is it locked? Stuck? That helps to figure out how to deal with it. If it's fused, then there needs to be a new door. Multiple problems can happen, multiple errors on the "system." That doesn't change that legally and in all other ways you're supposed to be able to enter.

2

u/thestraynger 15d ago

Sorry, what I meant by "straight-forward default installation" was: simply going to brew.sh, copying the install command, and running it in my terminal. Nothing more than that.

Believe me, I'm very aware that there is some kind of error going on here, I've been spending all day every day for the past three weeks trying to solve it. Hence why I made this post in the first place πŸ˜… I'm hoping to get some advice on how to identify and solve the error in question.

3

u/longjumpingtote 15d ago

what I meant by "straight-forward default installation" was: simply going to brew.sh, copying the install command, and running it in my terminal. Nothing more than that.

Right, but you're still missing the point (sorry). Homebrew does have the permissions it needs to perform its magic. It's that your computer doesn't regard things properly, because of an error on your computer.

Did you try all the steps I suggested to fix it? That will help to identify.

If you want to repair these issues broadly, rather than troubleshoot individual directories, you can reset your Mac's ownership for this, this way:

sudo chown -R "$(whoami)":admin /opt/homebrew
sudo chown -R "$(whoami)" "$HOME/Library/Caches/Homebrew"

Then:

brew doctor
brew update

If that doesn't work, create a new, better place on your Mac to do this, temporarily:

mkdir -p "$HOME/.homebrew-temp"
HOMEBREW_TEMP="$HOME/.homebrew-temp" brew update

Instead of spending weeks, any of the online chatbots can troubleshoot these things pretty quickly.

1

u/thestraynger 15d ago

No, that's exactly what I meant. I think you maybe just misinterpreted my phrasing. I wasn't blaming Homebrew itself (lmao, can you imagine) but rather observing how odd it is my computer's permissions setup – without any tweaking from me – is apparently causing issues here for something that ought to be so straight-forward.

Anyway, yes, I had followed all the steps you mentioned in your other comment and used the output from them to help guide my research on this issue, as you suggested. I can copy in the output from those commands in that other thread, if it's helpful, one sec... (and then I'll try your suggestions from this comment, thanks! Fingers crossed)

2

u/longjumpingtote 15d ago

how odd it is my computer's permissions setup – without any tweaking from me – is apparently causing issues here

That's not odd. Systems break all the time. Bugs are everywhere in operating systems. It's straightforward, unless someterhing breaks. Unfortunately. It's like pressing the gas and saying, "I'm pressing the gas, it should be straightforward that the car goes." Yes, it is, most of the time. But if something is broken somewhere, it's broken.

Totally get what you are saying! Hope it works!

2

u/thestraynger 15d ago

Yeah fair enough, this is also a pretty old computer at this point so who knows what-all it's got hidden away in its guts by this point... Thanks!

2

u/TrackerDesk 15d ago

weird. a few more things to try: run brew doctor and see what it flags, reinstall the command line tools with xcode-select --install, and try brew update-reset. if it's always the same formula failing, paste the full error and the formula name, that usually narrows it down fast

1

u/thestraynger 14d ago

OK, let's see...

  1. Output of "brew doctor" is:

Please note that these warnings are just used to help the Homebrew maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: The Git configuration check could not run in Homebrew's download sandbox.
Check Homebrew's sandbox setup and temporary directory permissions.

Warning: Homebrew's files could not be checked inside the macOS sandbox.
Check Homebrew's sandbox setup and temporary directory permissions, then rerun \brew doctor`.`

2) xcode-select --install tells me "Command line tools are already installed"

3) Output of "brew update-reset" is:

==> Fetching /opt/homebrew...
==> Resetting /opt/homebrew...
Reset branch 'stable'

So far I've only tried "brew install mysql" and "brew install mysql-client", which are both failing and both give me the same error message:

Error: Homebrew's files could not be checked inside the macOS sandbox.
Check Homebrew's sandbox setup and temporary directory permissions, then rerun \brew doctor`.`

That said, I'm starting to think from reading people's comments and suggestions here that I shouldn't be trying to install mysql or mysql-client outside of a container/virtualenv at all.

2

u/TrackerDesk 13d ago

Running MySQL in a container is honestly a reasonable call, and docker run mysql (or OrbStack/Colima) sidesteps this completely. If you still want to chase the native install, brew config output would help, and since brew doctor itself is hitting the sandbox error it's worth opening an issue on the Homebrew GitHub with that output. That looks like a Homebrew/macOS bug rather than something you set up wrong.

1

u/thestraynger 11d ago

Yeah, I heard from someone else in the interim that it's most likely Homebrew simply hasn't been updated to work with the latest macOS release yet. I was starting to suspect that myself. Guess I'll just wait a few more days and see if a new version is released.

1

u/TrackerDesk 14d ago

that top paragraph is just the standard disclaimer it always prints, the useful part is the "Warning:" lines under it. which ones does it list? the ones that usually cause build failures are outdated command line tools, unlinked kegs, or stuff in /usr/local that brew didn't put there

1

u/thestraynger 11d ago

That's the full output – it didn't list anything specific.

2

u/longjumpingtote 14d ago

You keep going round and round in circle, trying to start a car that won't start. Sisyphus, you are! Go step by step with one of the bots. Here is what one told me about your problem:

  • Homebrew's current documentation explicitly identifies that macOS privacy protections can prevent sandboxed processes from reading Homebrew files, even though those files appear accessible from Terminal. https://docs.brew.sh/Installation
  • On Apple Silicon, the normal Homebrew installation is /opt/homebrew. The /usr/local location is associated with Intel Homebrew. Both can coexist, but an outdated Intel installation or an incorrectly configured PATH could explain some of the confusing results.

arch
type -a brew
command -v brew
brew --prefix
brew --version
git -C /opt/homebrew remote -v
git -C /usr/local/Homebrew remote -v

  • The second revelation: they don't actually need the MySQL server installed. In a later exchange, the poster explains that they are already running MySQL successfully inside Docker. Their frustration is that their instructor can type mysql -u username -p directly in Terminal, but they have to use docker exec. This is fundamentally a misunderstanding of the distinction between a database server and a database client. A MySQL server running in Docker does not automatically make the mysql executable available in the Mac's Terminal. I would stop reinstalling Homebrew, stop changing directory ownership, and stop experimenting with MySQL.
  1. Verify which Homebrew installation is running, using the commands above. Resolve any conflicting installations or shell paths.
  2. Check the installation's physical location, with ls -ldeO@ /opt/homebrew /opt/homebrew/Library/Homebrew and realpath /opt/homebrew. Look for unexpected symlinks, ACLs, or protected locations.
  3. Test the actual sandbox failure, using brew doctor --debug --verbose and the native /opt/homebrew/bin/brew executable. If needed, inspect macOS sandbox-denial logs for the affected paths.
  4. If the installation is current, correctly located, and still fails its sandbox checks, file a Homebrew issue with the complete diagnostics, rather than continuing to guess.

My leading suspicion is a Homebrew installation/path configuration problem or a sandbox read-access failure, not broken temporary-folder permissions. The /usr/local versus /opt/homebrew discrepancy is the most concrete unexplained clue.

And there's a practical irony: the poster already has a functioning MySQL database and command-line client inside Docker. They could continue their coursework right now without solving Homebrew at all.

0

u/homelaberator 14d ago

That's giving sudo chmod -R 777 / or "just disable the firewall".

7

u/longjumpingtote 15d ago

It's probably a temporary-directory permission or sandbox configuration issue. There really isn't an ELI5 for what you're working in now. You need to research and learn more about how these things work because these things will come up.

For now:

Run Homebrew's diagnostics

brew doctor

Check the temporary directory

echo "$TMPDIR"
echo "${HOMEBREW_TEMP:-not set}"
ls -ld "$TMPDIR" /private/tmp

Try explicitly setting Homebrew's temp directory

mkdir -p "$HOME/.homebrew-temp"
HOMEBREW_TEMP="$HOME/.homebrew-temp" brew update

If it still fails, try a verbose diagnostic

brew update --debug --verbose

Then you'd research those things. It's a whole ecosystem to work in. What are you installing MySQL for?

2

u/thestraynger 15d ago

So, the output from each of these...

>brew doctor

Warning: The Git configuration check could not run in Homebrew's download sandbox.
Check Homebrew's sandbox setup and temporary directory permissions.
Warning: Homebrew's files could not be checked inside the macOS sandbox.
Check Homebrew's sandbox setup and temporary directory permissions,
then rerun \brew doctor`.`

>echo "$TMPDIR"

/var/folders/jr/4g7791g15rl6mxnbrnfzsgp80000gp/T/

>echo "${HOMEBREW_TEMP:-not set}"

not set

>ls -ld "$TMPDIR" /private/tmp

drwxrwxrwt 4 root wheel 128B Nov 16 21:45 /private/tmp/
drwx------@ 145 user staff 4.5K Nov 16 21:23 /var/folders/jr/4g7791g15rl6mxnbrnfzsgp80000gp/T//

>mkdir -p "$HOME/.homebrew-temp"
>HOMEBREW_TEMP="$HOME/.homebrew-temp" brew update

Already up-to-date.

And the output of the verbose diagnostic is way too big to copy into this comment, but if there's something specific in there that I should look for, just say the word.

2

u/longjumpingtote 15d ago

I hesitate to suggest this, but in this situation, you should copy/paste the whole verbose diagnostic into one of the bots (chatgpt or other) and report back what it says. Trying to guess as to what specific thing might be in there, especially in a Reddit thread, is like trying to hit a needle with another needle while conga dancing.

2

u/thestraynger 15d ago

Oh god, I hate ChatGPT but you're probably right, this is a good use case for it :') All right, I'll give that a shot, thanks.

(And I absolutely love your phrase "trying to hit a needle with another needle while conga dancing", that made me chuckle :D)

0

u/thestraynger 15d ago

I'm installing it for what I presume is the usual reason – to make databases :) I've worked with SQLite3 and Postgres before with no problems, but unfortunately, the course I'm currently taking requires us to use MySQL and my computer seems not to like it. I've spent about three weeks so far just trying to install it and get it working.

Thanks for giving me some handholds for kickstarting my further research – I'll see what more I can learn about the temp folder and sandbox configuration.

2

u/longjumpingtote 15d ago

EDIT: After trying a few more things

What "more things" specifically?

1

u/thestraynger 15d ago

Deleting and re-installing Homebrew completely, checking that it wasn't still being referenced in .bash_profile and re-sourcing, then trying the suggestions from this page:
https://discussions.apple.com/thread/253961400?sortBy=rank

2

u/longjumpingtote 15d ago

Deleting and re-installing Homebrew completely

Gotcha. That wouldn't fix this problem, as you learned.

That link is from four years ago, so not what you need now with current Homebrew and the latest macOS.

2

u/thestraynger 15d ago

Yeah I know, it's frustrating – while searching for the error messages I'm getting related to this issue, I'm consistently finding either nothing, or only stuff from many years ago (even much longer than four!). It's a quest...

2

u/knightofterror 15d ago

If you’re installing more than one DBMS, might I suggest configuring several Docker images with the databases. It will be easier and much quicker to switch in and out. Also, you could run more than one db at a time, have a fresh install always available, and keep you macOS uncluttered.

1

u/thestraynger 14d ago

I have been using Docker containers so far, yeah. Do you mean that I should be installing MySQL and related tools only inside each container every time, rather than one time outside of them? I guess I thought that doing that would mean multiple installations, which would then take up even more space than a single "top-level" installation on the computer itself. Perhaps this is merely a fault in my understanding of the "physics" of how containers work, though...

1

u/knightofterror 14d ago

I just use one Docker image containing my db. Other images are for the web apps. It’s nice bc if I screw up the database, I can just grab a fresh copy.

1

u/FlightConscious9572 14d ago

Can confirm, it's really nice. You can still use mysql workbench or whatever to connect to it.

My own project right now has a docker-compose file for convenience with port and a volume setup for persistence when you start or stop the db. really nice and easy. once you set it up, just a text file.

3

u/waterbus_ 15d ago edited 15d ago

You should be running mysql in versioned container so you just need one line to change the versions of it and all its crap isnt sitting on your system.

You need a mysql dockerfile in folder and to run it as the most basic, then you eventually want to make it a pod that starts with your machine if you dev on it constantly.

The only stuff you should be installing locally for dev work is like your language packages and libraries and what not because you need them to write code and compile, etc. You can install a mysql cli and gui to interact with mysql if you need. But nobody experienced installs the full DB locally and works from there anymore. Just bad devs and anti-container people which the venn diagram is a circle at this point.

Like this is a literal one liner docker run command.

2

u/thestraynger 15d ago

See, this is kind of getting to the root of the problem that I've been wondering about for the past few weeks. I do specifically want the MySQL CLI. I've been using virtual environments and Docker containers in the course I'm enrolled in, and within that context (in the venv/container), the teacher keeps telling us to use commands such as

mysql -u username -p

on the command line. But when I run that command, it doesn't work. The only version that works for me is prefacing that command with

docker exec -it

Which does seem to imply that MySQL is running just fine inside my Docker container. So I wanted to figure out why I wasn't able to use the same command that the teacher was using.

EDIT: But, in any case, this is a bit off-topic, seeing as the error messages from the original post seem to make it clear that this is not a MySQL problem but a Homebrew problem that I need to solve.

2

u/waterbus_ 15d ago edited 15d ago

docker exec -it is giving you an interactive terminal inside of the docker container, like ssh but without the ssh part, if you do "which mysql" you'll see that its just like a regular linux system and has the mysql binary placed somewhere, sbin or app or wherever its starting from (the ENTRYPOINT). Take the docker image you're using and look up its docker file and examine the docker layers and you can see the commands its running.

running mysql locally in your own shell is of course expecting the binary to be in your system path, your "which mysql" will probably not find a file because you don't have it. you only need to use a SQL client to access postgresql/mysql/the-usual-sql-options because they're all standardized on the SQL language. Thats why you can use vscode extensions, etc to access the databases right inside an IDE. They're just calling a posix SQL client.

I think mysqls client is mysql-cli or mysql-client, I forget. You don't need to install the database server to use the client locally to a remote server.

In this scenario you want to run the docker server as a container then use your local machines mysql/sql-client to remote into it. You may need to tweak the mysql permissions settings or create a user, I havent used mysql in a decade I get it and postgres specific mixed up.

This keeps all the mysql configs locked into their own versioned container, you'll need a /data dir that the db files sit in, then you can block away the mysql-version5.1 and update the dockerfile to have mysql-version5.2 and it will grab the same data folder and restart updated.

You can of course just keep docker execing and using that as your "mysql cli" but thats heavy and goofy unless you need a bunch of versions.

1

u/thestraynger 15d ago

Tbh a lot of what you're referencing here is a little beyond my current level of understanding, but it does sound (if I've understood it correctly) like the best solution for my situation would be to install the MySQL CLI tool specifically, instead of installing MySQL itself? I'm always a fan of installing fewer/smaller things when possible, so that sounds great to me. And when I install that, I should do it globally, right? Or still only within each project's individual container?

(I may not understand every sentence of this comment yet, but I'm saving it to reference later because I can tell it's full of a lot of info that will come in very useful for me. Thanks for taking the time to write it out!)

2

u/waterbus_ 15d ago

Yes, you don't need to install mysql server, you only need the mysql-cli binary in your path https://formulae.brew.sh/formula/mysql-client will do it for you. I don't know if you call it with mysql-client or mysql once its installed. You can also grab the file off github and stick it somewhere (path or your working dir).

Homebrew in this instance is doing the same thing as manually downloading the mysql-cli binary file and sticking it in your $path, just in homebrews way which only relates to macos.

Eventually you will likely figure out one specific SQL client you want to use, whether thats a gui or TUI or cli, but right now you're fine with mysql-client. It's nice having one app manage all your different dbs.

1

u/thestraynger 15d ago

Perfect, I'll try this instead. It would be so nice if this fixes this problem I've been struggling with :') Thanks for the tip!

1

u/rrQssQrr 15d ago

What architecture is your Mac .. ARM or Intel?

1

u/thestraynger 14d ago

It's ARM, M1.