Passer au contenu principal

Using Homebrew with Level on macOS

Mis à jour aujourd’hui

Introduction

Level manages Homebrew on macOS through a dedicated homebrew system user rather than running it as root or the currently logged-in user. This follows Homebrew's own recommendation and avoids permission issues that arise from running brew as root.

If you run Homebrew automation actions through Level and see unexpected behavior, or if you're managing a macOS device that already had Homebrew installed, this article explains what Level does and how to work with it.


The homebrew User

Level creates a homebrew user account automatically when either of these actions runs for the first time on a device:

  • Install Homebrew

  • Install Homebrew Package (which installs Homebrew first if it isn't already present)

The homebrew user is a system account (no login shell, no home directory in /Users). It's configured for passwordless sudo via a configuration file at /etc/sudoers.d/homebrew.

ℹ️ NOTE: If Homebrew was already installed on the device before any Level action ran, Level reconfigures the existing installation to transfer ownership to the homebrew user. Installed packages are preserved.


Running Homebrew Commands

Since Homebrew is owned by the homebrew user, brew commands must run as that user to work correctly.

The full command form is:

__PRESERVE_CODE_11__

Example:

__PRESERVE_CODE_12__

Using the Level Wrapper

Level installs a wrapper script at /usr/local/bin/brew that runs brew commands as the homebrew user automatically.

With the wrapper in place, you can use standard brew syntax:

__PRESERVE_CODE_15__

The wrapper handles the sudo -E -H -u homebrew prefix for you. Use this form when running brew commands in Level's terminal or in scripts.

💡 TIP: Always use the wrapper form in Level scripts and automations. Using brew directly (via the wrapper) keeps the syntax clean and ensures you're running in the correct user context.

Notification Banner

When running brew via the Level wrapper, you'll see a note similar to this:

__PRESERVE_CODE_18__

This is informational only. It confirms that Level's wrapper is active and that the homebrew user is managing the installation.


FAQ

  • Why does Level use a dedicated homebrew user instead of running as root? Homebrew explicitly discourages running as root because it installs software into shared paths and the root context causes permission problems across the system. A dedicated user with targeted passwordless sudo is the recommended pattern per Homebrew's own documentation.

  • I had Homebrew installed before Level. What changed? Level transferred ownership of the Homebrew installation to the homebrew user. Your installed packages are still there. Future installs and upgrades go through the homebrew user. If you were running brew commands as yourself or as root before, use the wrapper or the sudo -E -H -u homebrew brew form going forward.

  • Can I still install packages manually with brew install? Yes, using the wrapper at /usr/local/bin/brew or the full sudo -E -H -u homebrew brew install form. Direct brew install as root or another user will fail or create ownership conflicts.

  • What if I remove the homebrew user? The Level Homebrew actions will recreate the user and reconfigure ownership the next time they run. Don't remove it if you're using Level to manage Homebrew.

  • Can I use Homebrew with Level on Apple Silicon (M1/M2/M3) Macs? Yes. The homebrew user and wrapper approach works on both Intel and Apple Silicon. Note that Homebrew installs to different paths on each architecture (/usr/local vs /opt/homebrew), but Level handles this transparently.

Avez-vous trouvé la réponse à votre question ?