Brew core cmd broken

Hi there, my brew was broken for the reason i don’t know someday:

[sandbox:~]$ brew config
/bin/bash: /usr/local/Library/Homebrew/brew.sh: No such file or directory
[sandbox:~]$ brew doctor
/bin/bash: /usr/local/Library/Homebrew/brew.sh: No such file or directory
[sandbox:~]$

but when I run the script instead not the symbol link:

[sandbox:~]$ sh /usr/local/Homebrew/bin/brew config
HOMEBREW_VERSION: 2.1.15
ORIGIN: https://github.com/Homebrew/brew
HEAD: 2bf8015bc44878d432fb9da4f11e1d8abcef8f32
Last commit: 3 weeks ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 18e37e02262fb31723ef265d3ac1aa36555a63a8
Core tap last commit: 89 minutes ago
HOMEBREW_PREFIX: /usr/local/Homebrew
HOMEBREW_CELLAR: /usr/local/Homebrew/Cellar
HOMEBREW_GITHUB_API_TOKEN: set
CPU: quad-core 64-bit kabylake
Homebrew Ruby: 2.6.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3/bin/ruby
Clang: 10.0 build 1001
Git: 2.20.1 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 7.54.0 => /usr/bin/curl
Java: 1.8.0_131
macOS: 10.14.6-x86_64
CLT: 10.3.0.0.1.1562985497
Xcode: N/A

Why does it say sandbox? And what happens when you run brew upgrade?

The sandbox is just my username. I just did nothing when I install Xcode.

sh /usr/local/Homebrew/bin/brew doctor

What happens when you run this?

sh /usr/local/Homebrew/bin/brew update-reset
sh /usr/local/Homebrew/bin/brew update

Could you try running these?

I ran sh /usr/local/Homebrew/bin/brew subcommand, works fine. Should I add directory usr/local/Homebrew/bin to my PATH? because I am using the symbol link in /usr/bin.

and the doctor output as follow:

[sandbox:/usr/local]$ sh /usr/local/Homebrew/bin/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: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
  /Users/zhangze02/local/clang/bin/llvm-config
  /usr/local/php-7.1.12/bin/php-config
  /opt/local/bin/ncursesw5-config
  /opt/local/bin/ncurses5-config
  /usr/local/bin/icu-config
  /usr/local/bin/freetype-config
  /usr/local/bin/php-config

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
  /usr/local/lib/LibSideSyncOSX9.dylib
  /usr/local/lib/libZhongXinBank.dylib
  /usr/local/lib/libboost_atomic.dylib
  /usr/local/lib/libboost_chrono.dylib
  /usr/local/lib/libboost_container.dylib
  /usr/local/lib/libboost_context.dylib
  /usr/local/lib/libboost_coroutine.dylib
  /usr/local/lib/libboost_date_time.dylib
  /usr/local/lib/libboost_filesystem.dylib
  /usr/local/lib/libboost_graph.dylib
  /usr/local/lib/libboost_iostreams.dylib
  /usr/local/lib/libboost_locale.dylib
  /usr/local/lib/libboost_log.dylib
  /usr/local/lib/libboost_log_setup.dylib
  /usr/local/lib/libboost_math_c99.dylib
  /usr/local/lib/libboost_math_c99f.dylib
  /usr/local/lib/libboost_math_c99l.dylib
  /usr/local/lib/libboost_math_tr1.dylib
  /usr/local/lib/libboost_math_tr1f.dylib
  /usr/local/lib/libboost_math_tr1l.dylib
  /usr/local/lib/libboost_numpy.dylib
  /usr/local/lib/libboost_prg_exec_monitor.dylib
  /usr/local/lib/libboost_program_options.dylib
  /usr/local/lib/libboost_python.dylib
  /usr/local/lib/libboost_random.dylib
  /usr/local/lib/libboost_regex.dylib
  /usr/local/lib/libboost_serialization.dylib
  /usr/local/lib/libboost_signals.dylib
  /usr/local/lib/libboost_system.dylib
  /usr/local/lib/libboost_thread.dylib
  /usr/local/lib/libboost_timer.dylib
  /usr/local/lib/libboost_type_erasure.dylib
  /usr/local/lib/libboost_unit_test_framework.dylib
  /usr/local/lib/libboost_wave.dylib
  /usr/local/lib/libboost_wserialization.dylib
  /usr/local/lib/libcdt.5.dylib
  /usr/local/lib/libcgraph.6.dylib
  /usr/local/lib/libcrypto.1.1.dylib
  /usr/local/lib/libfreetype.6.dylib
  /usr/local/lib/libgd.dylib
  /usr/local/lib/libgflags.2.2.1.dylib
  /usr/local/lib/libgflags_nothreads.2.2.1.dylib
  /usr/local/lib/libgpdbcost.2.42.3.dylib
  /usr/local/lib/libgpdbcost.3.32.4.dylib
  /usr/local/lib/libgpopt.2.42.3.dylib
  /usr/local/lib/libgpopt.3.32.4.dylib
  /usr/local/lib/libgpos.1.147.dylib
  /usr/local/lib/libgpos.2.42.3.dylib
  /usr/local/lib/libgpos.3.32.4.dylib
  /usr/local/lib/libgvc.6.dylib
  /usr/local/lib/libgvpr.2.dylib
  /usr/local/lib/libhogweed.4.0.dylib
  /usr/local/lib/libicudata.42.1.dylib
  /usr/local/lib/libicudata.56.1.dylib
  /usr/local/lib/libicui18n.42.1.dylib
  /usr/local/lib/libicui18n.56.1.dylib
  /usr/local/lib/libicuio.42.1.dylib
  /usr/local/lib/libicuio.56.1.dylib
  /usr/local/lib/libicule.42.1.dylib
  /usr/local/lib/libicule.56.1.dylib
  /usr/local/lib/libiculx.42.1.dylib
  /usr/local/lib/libiculx.56.1.dylib
  /usr/local/lib/libicutest.56.1.dylib
  /usr/local/lib/libicutu.42.1.dylib
  /usr/local/lib/libicutu.56.1.dylib
  /usr/local/lib/libicuuc.42.1.dylib
  /usr/local/lib/libicuuc.56.1.dylib
  /usr/local/lib/libjpeg.9.dylib
  /usr/local/lib/liblab_gamut.1.dylib
  /usr/local/lib/libnaucrates.2.42.3.dylib
  /usr/local/lib/libnaucrates.3.32.4.dylib
  /usr/local/lib/libnettle.6.0.dylib
  /usr/local/lib/libpathplan.4.dylib
  /usr/local/lib/libpcre.0.dylib
  /usr/local/lib/libpng16.16.dylib
  /usr/local/lib/libssl.1.1.dylib
  /usr/local/lib/libxdot.4.dylib
  /usr/local/lib/libxerces-c-3.1.dylib
  /usr/local/lib/ss_conn_lib.dylib

Warning: Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected .la files:
  /usr/local/lib/libbfd.la
  /usr/local/lib/libfreetype.la
  /usr/local/lib/libjpeg.la
  /usr/local/lib/libopcodes.la
  /usr/local/lib/libpcre.la
  /usr/local/lib/libpcrecpp.la
  /usr/local/lib/libpcreposix.la
  /usr/local/lib/libpng16.la
  /usr/local/lib/libxerces-c.la

Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected .pc files:
  /usr/local/lib/pkgconfig/freetype2.pc
  /usr/local/lib/pkgconfig/gflags.pc
  /usr/local/lib/pkgconfig/hogweed.pc
  /usr/local/lib/pkgconfig/icu-i18n.pc
  /usr/local/lib/pkgconfig/icu-io.pc
  /usr/local/lib/pkgconfig/icu-le.pc
  /usr/local/lib/pkgconfig/icu-lx.pc
  /usr/local/lib/pkgconfig/icu-uc.pc
  /usr/local/lib/pkgconfig/libcdt.pc
  /usr/local/lib/pkgconfig/libcgraph.pc
  /usr/local/lib/pkgconfig/libcrypto.pc
  /usr/local/lib/pkgconfig/libgvc.pc
  /usr/local/lib/pkgconfig/libgvpr.pc
  /usr/local/lib/pkgconfig/liblab_gamut.pc
  /usr/local/lib/pkgconfig/libpathplan.pc
  /usr/local/lib/pkgconfig/libpng16.pc
  /usr/local/lib/pkgconfig/libssl.pc
  /usr/local/lib/pkgconfig/libxdot.pc
  /usr/local/lib/pkgconfig/nettle.pc
  /usr/local/lib/pkgconfig/openssl.pc
  /usr/local/lib/pkgconfig/proftpd.pc
  /usr/local/lib/pkgconfig/xerces-c.pc

Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected static libraries:
  /usr/local/lib/cairo-fdr.a
  /usr/local/lib/cairo-sphinx.a
  /usr/local/lib/libbfd.a
  /usr/local/lib/libboost_atomic.a
  /usr/local/lib/libboost_chrono.a
  /usr/local/lib/libboost_container.a
  /usr/local/lib/libboost_context.a
  /usr/local/lib/libboost_coroutine.a
  /usr/local/lib/libboost_date_time.a
  /usr/local/lib/libboost_exception.a
  /usr/local/lib/libboost_filesystem.a
  /usr/local/lib/libboost_graph.a
  /usr/local/lib/libboost_iostreams.a
  /usr/local/lib/libboost_locale.a
  /usr/local/lib/libboost_log.a
  /usr/local/lib/libboost_log_setup.a
  /usr/local/lib/libboost_math_c99.a
  /usr/local/lib/libboost_math_c99f.a
  /usr/local/lib/libboost_math_c99l.a
  /usr/local/lib/libboost_math_tr1.a
  /usr/local/lib/libboost_math_tr1f.a
  /usr/local/lib/libboost_math_tr1l.a
  /usr/local/lib/libboost_numpy.a
  /usr/local/lib/libboost_prg_exec_monitor.a
  /usr/local/lib/libboost_program_options.a
  /usr/local/lib/libboost_python.a
  /usr/local/lib/libboost_random.a
  /usr/local/lib/libboost_regex.a
  /usr/local/lib/libboost_serialization.a
  /usr/local/lib/libboost_signals.a
  /usr/local/lib/libboost_system.a
  /usr/local/lib/libboost_test_exec_monitor.a
  /usr/local/lib/libboost_thread.a
  /usr/local/lib/libboost_timer.a
  /usr/local/lib/libboost_type_erasure.a
  /usr/local/lib/libboost_unit_test_framework.a
  /usr/local/lib/libboost_wave.a
  /usr/local/lib/libboost_wserialization.a
  /usr/local/lib/libcairo-trace.a
  /usr/local/lib/libcoregrind-amd64-darwin.a
  /usr/local/lib/libcrypto.a
  /usr/local/lib/libfreetype.a
  /usr/local/lib/libgflags.a
  /usr/local/lib/libgflags_nothreads.a
  /usr/local/lib/libhogweed.a
  /usr/local/lib/libjpeg.a
  /usr/local/lib/liblua.a
  /usr/local/lib/libnettle.a
  /usr/local/lib/libopcodes.a
  /usr/local/lib/libpng16.a
  /usr/local/lib/libreplacemalloc_toolpreload-amd64-darwin.a
  /usr/local/lib/libssl.a
  /usr/local/lib/libvex-amd64-darwin.a
  /usr/local/lib/libvexmultiarch-amd64-darwin.a
  /usr/local/lib/libxerces-c.a
  /usr/local/lib/liby.a

Warning: Your Homebrew's prefix is not /usr/local.
Some of Homebrew's bottles (binary packages) can only be used with the default
prefix (/usr/local).
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Discourse, Twitter or IRC. You are responsible for resolving any issues you
experience while you are running this unsupported configuration.


Warning: Homebrew's bin was not found in your PATH.
Consider setting the PATH for example like so:
  echo 'export PATH="/usr/local/Homebrew/bin:$PATH"' >> ~/.bash_profile

There should not be a link in /usr/bin. You should follow the last instructions in brew doctor and add it to your path yeah.

1 Like