brew or a Homebrew-installed tool returns “command not found” on your remote Mac.

Fastest fix: confirm the command’s account, active shell, and actual Homebrew prefix, then load brew shellenv in the startup path that this exact execution environment reads.

This is for developers using Homebrew over SSH, engineers maintaining macOS CI or background jobs, and platform owners troubleshooting shared remote Macs.

If an interactive terminal works but CI does not, fix the CI account or shell environment. Don’t reinstall Homebrew or change permissions until you’ve identified evidence that those are the cause.

01

Remote Mac Homebrew command not found: identify the failing layer

“Command not found” does not tell you whether Homebrew is missing. It only tells you that the current shell could not resolve the command it was asked to run.

First, separate the failure into one of these cases:

  • The brew command itself is missing. The current shell may not have Homebrew’s bin directory in PATH, or it may be using a different account from the one that installed Homebrew.
  • brew runs, but an installed tool does not. The package may not be installed for this environment, its executable may be in a different directory, or the command name may differ from the formula name.
  • The command works interactively but fails in an automatic task. The task may run under another user or shell, or start without the environment variables you set in your interactive configuration.

Capture the failure before editing a file. Record the exact command, the full error output, the login method, and the user that runs the failing process. Then compare those details with a shell where the command works.

Why does SSH fail to find brew when a terminal session can run it? The two sessions may not read the same startup files. A terminal window often starts an interactive shell; an SSH command or CI process may start a non-interactive shell and skip configuration you expected it to load.

Use these commands in the failing context where possible:

whoami
echo "$SHELL"
ps -p $$ -o comm=
printf '%s\n' "$PATH"
command -v brew

$SHELL records the account’s configured login shell, while ps helps identify the shell process currently running. They can differ. command -v brew reports whether the active shell can resolve brew; it does not prove which installation is present on the machine.

For a first comparison, run the same diagnostics in a working interactive terminal and in the failing SSH or automation context. A difference in user, shell, or PATH narrows the investigation without changing the node.

02

Step one: verify the Homebrew prefix and executable

If the shell cannot find brew, establish where Homebrew is installed before adding paths. Homebrew’s documentation gives different default prefixes for Apple Silicon and Intel Macs: /opt/homebrew and /usr/local, respectively. Treat these as documented defaults, not as proof of the prefix on your host. Confirm the actual location on the machine you are diagnosing using the Homebrew installation documentation and its FAQ on installation prefixes.

When brew is available in any context on that host, run:

brew --prefix
command -v brew
brew config

brew --prefix reports the active installation prefix. command -v brew identifies the executable selected by the current shell. brew config provides diagnostic details about the installation and environment; consult the Homebrew command manual for supported command behavior.

If the failing shell cannot resolve brew, test the documented prefix paths only as a diagnostic, not as a permanent assumption:

test -x /opt/homebrew/bin/brew && echo "Found executable at /opt/homebrew/bin/brew"
test -x /usr/local/bin/brew && echo "Found executable at /usr/local/bin/brew"

A match tells you an executable exists at that path. It does not, by itself, establish that the path is the intended installation for this account. Confirm the host’s architecture and compare the result with the account and working environment. If you have multiple installations or an unexpected prefix, stop and investigate before adding another Homebrew installation.

To check the architecture reported by the current process, use:

uname -m

Then compare it with brew config from the installation you intend to use. The important distinction is not just “Apple Silicon or Intel.” It is whether the executable, installation prefix, shell environment, and executing account all refer to the same intended setup.

How do you confirm the Homebrew path on Apple Silicon versus Intel? Check the host and active installation; don’t infer either from a copied setup snippet. The documented default prefixes are /opt/homebrew for Apple Silicon and /usr/local for Intel, but your host’s brew --prefix and executable path are the evidence to use.

Once you have confirmed the intended executable, initialize its environment in the current shell:

eval "$(/actual/prefix/bin/brew shellenv)"

Replace /actual/prefix with the prefix you just verified. Homebrew’s shellenv command emits shell settings for the installation, including PATH updates. Its documented behavior is described in the Homebrew manpage. Avoid pasting a prefix from a guide without checking it against the host.

03

Step two: match SSH startup files to the active shell

A valid installation can remain invisible when the configuration that adds Homebrew to PATH is not loaded by the shell that receives the command. Identify the actual shell first. Do not assume every remote shell is Bash, or that a file used by a terminal app also runs during SSH commands.

For zsh, startup behavior depends on whether the shell is a login shell, an interactive shell, or both. The zsh startup-file documentation distinguishes files such as .zshenv, .zprofile, and .zshrc. In particular, .zshenv is read by zsh invocations, while .zprofile is associated with login shells and .zshrc with interactive shells. That distinction matters when an SSH command is non-interactive.

For Bash, check the startup rules for the shell mode you actually use rather than copying a zsh configuration line. A configuration placed in a file that your command never reads cannot repair the command’s environment.

A safe diagnostic sequence is:

echo "$0"
ps -p $$ -o comm=
printf '%s\n' "$PATH"
command -v brew

Then reproduce the failing command with the same SSH form used by the caller. Compare an interactive login with a direct remote command. For example, these are different tests:

ssh user@host
ssh user@host 'command -v brew; printf "%s\n" "$PATH"'

The first opens a session in which you can interact. The second runs a command through SSH and prints the environment available to that process. Use your actual host and account; the examples are not a claim about any particular remote configuration.

Make the smallest change that matches the execution path. If the failing process is an interactive zsh shell, update the relevant interactive configuration. If it is a login shell, ensure the login path initializes Homebrew. If a non-interactive task needs Homebrew, either configure the task’s environment explicitly or invoke the verified executable path. Then reconnect and retest.

Don’t move brew shellenv into every shell file as a precaution. Duplicate initialization can obscure which file is responsible and make different entry points behave inconsistently.

04

Step three: inspect the account and shell used by CI or background work

When Homebrew works in your own SSH session but not in a runner, scheduled job, or service, inspect the process that actually executes the task. A successful command in an administrator’s terminal is not evidence that the runner has the same PATH, account, permissions, or shell.

Start with the task’s own logs. Add temporary diagnostic output at the beginning of a test job:

whoami
echo "$SHELL"
ps -p $$ -o comm=
printf 'PATH=%s\n' "$PATH"
command -v brew || true

If the task launches a separate script, put diagnostics in that script as well. The environment used to start the runner may differ from the environment that runs a job. Check the service or runner configuration, its launch method, the configured shell, and the user assigned to the process. For a self-hosted GitHub Actions runner, use the official runner monitoring and troubleshooting guidance alongside the logs produced by your own workflow.

How do you establish which account and shell an automatic task uses? Print whoami, the running shell, and PATH from inside the task, then compare the output with the expected service configuration. Do not rely only on the account you used to register or administer the runner.

If the task’s PATH lacks the verified Homebrew prefix, add the initialization to the task’s own startup path or configure the job environment explicitly. For a controlled CI script, calling the verified executable can be clearer than relying on an interactive shell:

/actual/prefix/bin/brew --version

After that succeeds, test the installed program required by the job. Keep the explicit path tied to the prefix you verified on that node; don’t assume it is identical across different Mac architectures or runner images.

For a scheduled task, review how the scheduler launches the command and what environment it supplies. For a service, inspect its launch configuration and logs. The fix is successful only when the actual task can resolve and execute the required command—not merely when a person can run it in a terminal.

05

Step four: investigate permissions before changing ownership

Sometimes brew exists but cannot be read or executed, or Homebrew reports a write-permission error. That is a different failure from a missing PATH entry. Check the target account, the executable, and the prefix before changing ownership:

whoami
ls -ld /actual/prefix
ls -ld /actual/prefix/bin
ls -l /actual/prefix/bin/brew

Compare the output with the account intended to manage the installation and the account that needs to run the command. Homebrew documents its installation and permissions model, including guidance for Mac administrators managing accounts, in Homebrew for Mac admins. Use that guidance to assess whether the prefix and its owner match your management model.

Avoid recursive ownership changes, broad permission changes, or running package operations with elevated privileges as a default response. These actions can affect unrelated files, hide the original cause, or leave the machine in a state that another user cannot maintain. Homebrew’s common-issues documentation is a better reference when an error specifically concerns permissions or a damaged installation.

Use a decision based on the evidence:

  • If the executable is present and readable, but command -v brew fails only in one shell, repair that shell’s environment.
  • If the task runs under an unexpected account, correct the runner or service configuration before altering the installation.
  • If the prefix owner or permissions conflict with the intended account model, review the Homebrew management guidance and make a scoped correction.
  • If the executable, prefix, or node baseline cannot be trusted, document the findings and evaluate a clean rebuild rather than layering speculative fixes.
06

Validate the repair in every failing context

A local terminal test is necessary, but it is not enough when the incident occurs in SSH or automation. Recheck the environment that originally failed and confirm both the command lookup and the actual work.

Use this checklist after making a change:

  • [ ] Record the account and running shell from the failing context.
  • [ ] Confirm the active Homebrew prefix and the executable path.
  • [ ] Confirm that the shell or job receives the intended Homebrew environment.
  • [ ] Run command -v brew and brew --prefix where brew is available.
  • [ ] Run the specific installed tool that the original task needs.
  • [ ] Repeat the test through the original SSH command, runner job, service, or scheduler.
  • [ ] Save the task output, exit status, and relevant environment details with the change record.

For an SSH issue, validate both an interactive login and the direct command form used by scripts. For a CI failure, run a representative workflow and inspect its own logs. For a background service, restart or reload it only when your configuration change requires that action, then confirm the service’s next execution.

When should you repair the shell, the account, or the node? Repair the shell when the correct user and installation are present but initialization is missing. Repair the account or runner configuration when the task runs under an unintended identity or shell. Consider rebuilding or replacing the node only when the installation state, ownership model, or baseline is inconsistent enough that a scoped correction cannot be verified.

This distinction prevents a common cycle: reinstall Homebrew, see no change in CI, then broaden permissions without checking which user ran the job. A logged result from the original execution context gives you a defensible basis for either a small environment fix or a node-level reset.

07

Choose a repeatable remote Mac environment when the node is the problem

A local workaround can be reasonable when you control the Mac and the issue is limited to one shell. It becomes harder to maintain when developers, SSH sessions, and CI services rely on different accounts or startup configurations. The trade-off is operational: keeping a self-managed node gives you more direct control, but you also own its baseline, access, and recovery process.

A Linux host may be easy to administer, but it cannot provide the macOS toolchain required by macOS-specific build tasks. A developer’s local Mac can validate a change, but it may not reproduce the CI service account or stay available as a shared execution node. A virtual or improvised environment can introduce further differences from the real Mac environment you need to test. None of these options is automatically wrong; choose based on whether you need a reproducible macOS execution context, physical access, sustained use, or control over the host.

If you already have a Mac but need to compare the cost of maintaining it against a time-bounded remote environment, review the available remote Mac rental options and pricing. Renting is not a substitute for every setup: long-running, steady workloads may justify owning a dedicated Mac, and work that needs local peripherals requires physical access.

If the issue is that your current node is difficult to reproduce or you need a temporary macOS environment to verify SSH and CI behavior, a VpsMesh remote Mac gives you a real Mac host to configure and test without buying hardware first. Check the VpsMesh remote Mac options against your workload and access needs; choose a rental only when its term and remote-access model fit the job.