Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
41.31k stars 9.71k forks source link

Unset `HOMEBREW_PATH` from the user's environment #13548

Closed ellardli closed 2 years ago

ellardli commented 2 years ago

brew config output

$ brew config
HOMEBREW_VERSION: 3.5.4
ORIGIN: https://github.com/Homebrew/brew
HEAD: 88a5fac96752f17280e64f60926f58dff45990e0
Last commit: 7 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 4ba206dbf122b438241793f5f65b788f92bf9edd
Core tap last commit: 2 days ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 2.6.8 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: 10-core 64-bit arm_firestorm_icestorm
Clang: 13.1.6 build 1316
Git: 2.32.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.79.1 => /usr/bin/curl
macOS: 12.4-arm64
CLT: 13.4.0.0.1.1651278267
Xcode: 13.4.1
Rosetta 2: false

brew doctor output

$ brew doctor
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: 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"' >> ~/.zshrc

Verification

What were you trying to do (and why)?

I tried running brew services to begin to run Redis, and received errors while trying to do so. I then ran brew doctor to attempt to debug the cause, which lead me to the bin/sbin PATH error.

What happened (include all command output)?

$ brew services
Usage: brew services [subcommand]

Manage background services with macOS' launchctl(1) daemon manager.

If sudo is passed, operate on /Library/LaunchDaemons (started at boot).
Otherwise, operate on ~/Library/LaunchAgents (started at login).

[sudo] brew services [list] (--json):
    List information about all managed services for the current user (or root).

[sudo] brew services info (formula|--all|--json):
    List all managed services for the current user (or root).

[sudo] brew services run (formula|--all):
    Run the service formula without registering to launch at login (or boot).

[sudo] brew services start (formula|--all|--file=):
    Start the service formula immediately and register it to launch at login
(or boot).

[sudo] brew services stop (formula|--all):
    Stop the service formula immediately and unregister it from launching at
login (or boot).

[sudo] brew services kill (formula|--all):
    Stop the service formula immediately but keep it registered to launch at
login (or boot).

[sudo] brew services restart (formula|--all):
    Stop (if necessary) and start the service formula immediately and register
it to launch at login (or boot).

[sudo] brew services cleanup:
    Remove all unused services.

      --file                       Use the service file from this location to
                                   start the service.
      --all                        Run subcommand on all services.
      --json                       Output as JSON.
  -d, --debug                      Display any debugging information.
  -q, --quiet                      Make some output more quiet.
  -v, --verbose                    Make some output more verbose.
  -h, --help                       Show this message.

Error: Invalid usage: `brew services` is supported only on macOS or Linux (with systemd)!
$ brew doctor --debug
==> Checking check_access_directories
==> Checking check_brew_git_origin
/opt/homebrew/Library/Homebrew/shims/shared/git --version
==> Checking check_broken_sdks
==> Checking check_cask_environment_variables
==> Checking check_cask_install_location
==> Checking check_cask_load_path
==> Checking check_cask_quarantine_support
==> Checking quarantine support
/usr/bin/xattr -h
/usr/bin/swift -target arm64-apple-macosx12 /opt/homebrew/Library/Homebrew/cask/utils/quarantine.swift
==> Quarantine is available.
==> Checking check_cask_software_versions
==> Checking check_cask_staging_location
==> Checking check_cask_taps
==> Checking check_cask_xattr
/usr/bin/xattr -h
==> Checking check_casktap_integrity
==> Checking check_clt_minimum_version
==> Checking check_clt_up_to_date
==> Checking check_coretap_integrity
==> Checking check_deleted_formula
==> Checking check_deprecated_caskroom_taps
==> Checking check_deprecated_disabled
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/pkg-config.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/vim.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libtiff.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libtool.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/coreutils.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/gmp.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/asdf.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/wget.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libidn2.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/imagemagick@6.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libxml2.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/little-cms2.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/git-duet/homebrew-tap/git-duet.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libpng.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/ncurses.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/ghostscript.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/nettle.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/gdbm.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/mpdecimal.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/gnu-getopt.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/cmake.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/freetype.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/redis.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libunistring.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/openjpeg.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libyaml.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/xmlto.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/bdw-gc.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/opensearch.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/icu4c.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/shared-mime-info.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/perl.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/glib.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/readline.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/utf8proc.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/awscli.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/optipng.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/webp.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/sqlite.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libgpg-error.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libxmlsec1.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/xz.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/unixodbc.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libnghttp2.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/lua.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libgcrypt.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/fontconfig.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/openjdk.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/giflib.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/docbook-xsl.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/nomad.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/krb5.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/ca-certificates.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/gettext.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/jbig2dec.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/autoconf.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libpq.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/tmux.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/m4.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libtasn1.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/oniguruma.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/pcre2.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libevent.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/openssl@1.1.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/pcre.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/python@3.10.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libidn.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/docbook.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/six.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/unbound.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/jpeg.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/jq.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/ripgrep.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/guile.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/jpegoptim.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/p11-kit.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/ruby.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/fzf.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/automake.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/libffi.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/python@3.9.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/vault.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/gnutls.rb
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/berkeley-db.rb
==> Checking check_deprecated_official_taps
==> Checking check_exist_directories
==> Checking check_filesystem_case_sensitive
==> Checking check_for_anaconda
==> Checking check_for_bitdefender
==> Checking check_for_config_scripts
==> Checking check_for_external_cmd_name_conflict
==> Checking check_for_gettext
==> Checking check_for_git
==> Checking check_for_iconv
==> Checking check_for_installed_developer_tools
==> Checking check_for_multiple_volumes
==> Checking check_for_non_prefixed_coreutils
==> Checking check_for_non_prefixed_findutils
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/findutils.rb
==> Checking check_for_other_frameworks
==> Checking check_for_pydistutils_cfg_in_home
==> Checking check_for_stray_dylibs
==> Checking check_for_stray_headers
==> Checking check_for_stray_las
==> Checking check_for_stray_pcs
==> Checking check_for_stray_static_libs
==> Checking check_for_symlinked_cellar
==> Checking check_for_tap_ruby_files_locations
==> Checking check_for_unlinked_but_not_keg_only
==> Checking check_for_unreadable_installed_formula
==> Checking check_for_unsupported_macos
==> Checking check_git_newline_settings
==> Checking check_git_status
==> Checking check_git_version
==> Checking check_homebrew_prefix
==> Checking check_if_supported_sdk_available
==> Checking check_if_xcode_needs_clt_installed
==> Checking check_multiple_cellars
==> Checking check_ruby_version
==> Checking check_tap_git_branch
==> Checking check_tmpdir
==> Checking check_tmpdir_sticky_bit
==> Checking check_user_path_1
==> Checking check_user_path_2
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: 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
==> Checking check_user_path_3

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"' >> ~/.zshrc
==> Checking check_xcode_license_approved
==> Checking check_xcode_minimum_version
==> Checking check_xcode_prefix
==> Checking check_xcode_prefix_exists
==> Checking check_xcode_select_path
==> Checking check_xcode_up_to_date
==> Checking check_for_broken_symlinks
==> Checking check_missing_deps
$ echo $PATH
/opt/homebrew/opt/libpq/bin:/opt/homebrew/sbin:/opt/homebrew/bin:/Users/ellard.li/.asdf/shims:/opt/homebrew/opt/asdf/libexec/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/ellard.li/workspace/dotfiles/bin:/opt/homebrew/opt/fzf/bin:/opt/homebrew/imagemagick@6/bin
# Added the echo statements below as recommended in https://github.com/orgs/Homebrew/discussions/3115#discussioncomment-3122270
$ echo ${ZDOTDIR:-${HOME}}
/Users/ellard.li

$ cat ${ZDOTDIR:-${HOME}}/.zshenv
cat: /Users/ellard.li/.zshenv: No such file or directory

What did you expect to happen?

Based on my $PATH, I would've expected that I wouldn't have received an error about /opt/homebrew/bin or /opt/homebrew/sbin not being in my PATH.

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

This was on a fresh M1 Mac.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# I added the following to my .zshrc file, without the comments
# export PATH="/opt/homebrew/bin:$PATH"
# export PATH="/opt/homebrew/sbin:$PATH"
# export PATH="$PATH:$(brew --prefix)/imagemagick@6/bin"
# export PATH="$(brew --prefix)/opt/libpq/bin:$PATH"

brew services

# After services ran the initial setup, I received the error shown in the command output block.

brew doctor

# I saw the error shown in the command output block
MikeMcQuaid commented 2 years ago
# I added the following to my .zshrc file, without the comments
# export PATH="$PATH:$(brew --prefix)/imagemagick@6/bin"
# export PATH="$(brew --prefix)/opt/libpq/bin:$PATH"

If this is all you did: this is not enough.

Can you still reproduce brew doctor message and PATH output this in a new shell after installation?

ellardli commented 2 years ago

Hey @MikeMcQuaid ! Thanks for that callout. I also added the following to .zshrc and forgot to add it to the ticket. Adding it now.

export PATH="/opt/homebrew/bin:$PATH"
export PATH="/opt/homebrew/sbin:$PATH"

The brew doctor and PATH output is what i'm getting right now after a couple of restarts.

carlocab commented 2 years ago

I can reproduce this with:

❯ brew doctor check_user_path_2
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: Homebrew's "bin" was not found in your PATH.
Consider setting your PATH for example like so:
  echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
❯ echo $PATH | rg -q ':/usr/local/bin:' && echo "Homebrew bin present"
Homebrew bin present

Oddly, the check_user_path_2 warning does not appear with just brew doctor.

Edit: Ah, never mind. check_user_path_2 needs to be run after check_user_path_1 in order to work.

carlocab commented 2 years ago

What's the output of

brew ruby -e 'require "utils"; puts paths'

?

ellardli commented 2 years ago

Output is the following:

$ brew ruby -e 'require "utils"; puts paths'
/opt/homebrew
carlocab commented 2 years ago

Ah. Do

unset HOMEBREW_PATH

Use HOMEBREW_PREFIX if you want an environment variable that refers to /opt/homebrew.

You also may want to avoid setting anything HOMEBREW_* that isn't documented in man brew, as that has the potential to break things.

ellardli commented 2 years ago

Hey @carlocab . That fixed it, thank you!

I'd like to understand why unsetting that env variable fixed it, and how you were able to debug that. Now that you've called it out, I do see that the setup scripts that my place has set up does run export HOMEBREW_PATH='/opt/homebrew'. How were you able to tell that the env variable was set and that it was a problem?

gromgit commented 2 years ago

Homebrew copies certain important environment variables into HOMEBREW_-prefixed ones...unless the latter already exists: https://github.com/Homebrew/brew/blob/721a27d68d63775176567ecba6c4a5b793130618/bin/brew#L76-L88

Because you set HOMEBREW_PATH, brew did not copy your existing PATH, so brew doctor examined your HOMEBREW_PATH and went "wait, where's my bin directory?"

carlocab commented 2 years ago

What @gromgit said.

If you need to keep your HOMEBREW_PATH variable (since you suggested this was something you didn't personally set), you can also do

alias brew="HOMEBREW_PATH= brew"
MikeMcQuaid commented 2 years ago

@gromgit @carlocab I wonder if we should explicitly unset HOMEBREW_PATH in bin/brew?

gromgit commented 2 years ago

That's probably a good idea. All the "derived" variables listed are either;

except HOMEBREW_PATH.

carlocab commented 2 years ago

@gromgit @carlocab I wonder if we should explicitly unset HOMEBREW_PATH in bin/brew?

I'm not necessarily opposed to it, but this would be a bit like playing whack-a-mole. I recall users having problems from setting other HOMEBREW_* variables too. I think it was HOMEBREW_PREFIX.

ellardli commented 2 years ago

What @gromgit said.

If you need to keep your HOMEBREW_PATH variable (since you suggested this was something you didn't personally set), you can also do

alias brew="HOMEBREW_PATH= brew"

We chose to namespace our variable to prevent further collisions. Based on the convo and in retrospect, we should've done that to prevent collisions that we weren't aware of at the time and moving forward.

carlocab commented 2 years ago

Related: https://github.com/Homebrew/homebrew-services/issues/494