BugMedic

Homebrew “detected dubious ownership”: mark the prefix safe

Tell git the Homebrew prefix is safe with git config --global --add safe.directory.

By BugMedic editorial teamLast source review: 2026-10-03macOS, Linux

This is git's ownership guard on Homebrew's checkout, not a broken install. Run git config --global --add safe.directory /opt/homebrew (or the path in the error), then brew update again.

Try these fixes in order

01

Identify the flagged paths

Confirm which paths git is complaining about; each needs its own safe.directory entry.

brew update 2>&1 | grep -i dubious
02

Mark the prefix as safe

This tells git you trust the Homebrew checkout. Repeat for any other path the error names.

git config --global --add safe.directory /opt/homebrew
03

Retry the update

With the guard satisfied, the update proceeds normally.

brew update
04

Check brew doctor

If ownership warnings remain, address exactly what it reports rather than blanket-chowning the prefix.

brew doctor

Interpret what you see

The error appears on brew update, not on installs

What it suggests: Git refuses to operate on repositories owned by a different user; Homebrew's prefix is a git checkout, so every brew update trips the guard.

Next check: Add the prefix to git's safe.directory list.

The error names /home/linuxbrew/.linuxbrew or a tap path

What it suggests: The same guard fires for the Linux prefix and for the homebrew-core tap checkout.

Next check: Add each reported path to safe.directory as well.

brew doctor reports ownership warnings

What it suggests: If the prefix is genuinely owned by the wrong user, brew doctor will say so; only then is an ownership fix appropriate.

Next check: Run brew doctor and follow its specific advice.

Why this happens

  • Git's safe.directory protection rejects the Homebrew prefix because its owner differs from the user running brew.
  • Ownership of the prefix changed (migration, restore, or another user ran the installer).

Still not working?

Do not sudo chown -R the prefix to silence this without checking who should own it; Homebrew's own docs warn against applying ownership changes from old issue reports blindly. Marking the directory safe in git config is the targeted fix.

Official sources

These steps are based on the linked documentation and general diagnostics. BugMedic has not independently tested every product and system configuration. Review commands before running them.

Related Homebrew guides