Skip to content

/opt/homebrew/bin/brew shellenv uses invalid syntax on fish 4.2.1 #21382

@fdemb

Description

@fdemb

brew doctor output

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: /usr/bin occurs before /opt/homebrew/bin in your PATH.
This means that system-provided programs will be used instead of those
provided by Homebrew. Consider setting your PATH so that
/opt/homebrew/bin occurs before /usr/bin. Here is a one-liner:
  echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc

The following tools exist at both paths:
  ctags
  openssl
  tidy

Warning: Homebrew's "bin" was not found in your PATH.
Consider setting your PATH for example like so:
  echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc

Warning: Homebrew's "sbin" was not found in your PATH but you have installed
formulae that put executables in /opt/homebrew/sbin.
Consider setting your PATH for example like so:
  echo 'export PATH="/opt/homebrew/sbin:$PATH"' >> ~/.zshr

Verification

  • I ran brew update twice and am still able to reproduce my issue.
  • My "brew doctor output" above says Your system is ready to brew or a definitely unrelated Tier message.
  • This issue's title and/or description do not reference a single formula e.g. brew install wget. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead.

brew config output

HOMEBREW_VERSION: 5.0.9-39-g4bddcb1
ORIGIN: https://github.com/Homebrew/brew
HEAD: 4bddcb1b00e15ab2c40a787108ba4d4c43917736
Last commit: 16 hours ago
Branch: main
Core tap JSON: 09 Jan 20:38 UTC
Core cask tap JSON: 09 Jan 20:38 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_DOWNLOAD_CONCURRENCY: 16
HOMEBREW_EDITOR: nvim
HOMEBREW_FORBID_PACKAGES_FROM_PATHS: set
HOMEBREW_MAKE_JOBS: 8
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 3.4.8 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.4.8/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 17.0.0 build 1700
Git: 2.50.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 26.2-arm64
CLT: 26.2.0.0.1.1764812424
Xcode: 26.2
Metal Toolchain: 17.0 (17C48)
Rosetta 2: false

What were you trying to do (and why)?

I installed some formula (or cask) that provided man pages. Homebrew seemed to add some new lines for man page finding to its shellenv. One of those lines is this:

[ -z "${MANPATH-}" ] || export MANPATH=":${MANPATH#:}";

Fish doesn't like this ${} syntax, and the result is this error:

- (line 6): ${ is not a valid variable in fish.
[ -z "${MANPATH-}" ] || export MANPATH=":${MANPATH#:}";
       ^
from sourcing file -
	called on line 8 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
	called during startup
source: Error while reading file '<stdin>'

This causes fish to not evaluate any homebrew commands in shellenv, hence the lack of /opt/homebrew/bin in PATH in the brew doctor output.

What happened (include all command output)?

Fish printed this (after running /opt/homebrew/bin/brew shellenv | source in fish.config):

- (line 6): ${ is not a valid variable in fish.
[ -z "${MANPATH-}" ] || export MANPATH=":${MANPATH#:}";
       ^
from sourcing file -
	called on line 8 of file ~/.config/fish/config.fish
from sourcing file ~/.config/fish/config.fish
	called during startup
source: Error while reading file '<stdin>'

What did you expect to happen?

The shellenv command should use a different way to check for MANPATH. Then the shellenv command would work, brew would add /opt/homebrew/bin/ and /opt/homebrew/sbin to PATH and add its man page directory to MANPATH.

Step-by-step reproduction instructions (by running brew commands)

1. Install homebrew on an ARM Mac using the default zsh shell.
2. Install fish with `brew install fish` and set it as the default shell.
3. Add `/opt/homebrew/bin/brew shellenv | source` to `~/.config/fish/config.fish` to load shellenv commands.
4. Install any cask or formula that provides man pages, e.g. ghostty: `brew install --cask ghostty`.
5. Restart the fish shell or try to run `/opt/homebrew/bin/brew shellenv | source` again. The error I mentioned before should appear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions