首先说下我遇到的问题,brew install
(venv_mac) haypin@HaypinsMBP /usr/local/Cellar brew install cmake
Error: [email protected]: wrong number of arguments (given 1, expected 0)
既使退出前面的虚拟环境也不行,我打开调试信息发现:
(venv_mac) ✘ haypin@HaypinsMBP /usr/local/Cellar brew install --debug cmake
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/sphinx-doc.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/[email protected]
Error: [email protected]: wrong number of arguments (given 1, expected 0)
可执行程序/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): 总是会加载loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/[email protected],从而报错python3.9传参错误。
网上说brew install cmake能解决问题,但我cmake已经安装的前提下仍然报这个错,没办法,只能重装Homebrew,寄希望于新的homebrew-core/[email protected]能正常执行
(venv_mac) ✘ haypin@HaypinsMBP /usr/local/Cellar /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Warning: The Ruby Homebrew uninstaller is now deprecated and has been rewritten in
Bash. Please migrate to the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
^C
发现卸载Homebrew的脚本还过期了,建议使用:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
那就用这个:
(venv_mac) ✘ haypin@HaypinsMBP /usr/local/Cellar /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
Warning: This script will remove:
/Users/haypin/Library/Caches/Homebrew/
/Users/haypin/Library/Logs/Homebrew/
/usr/local/Caskroom/
/usr/local/Cellar/
/usr/local/bin/brew -> /usr/local/bin/brew
Are you sure you want to uninstall Homebrew? This will remove your installed packages! [y/N] y
==> Removing Homebrew installation...
Warning: Failed to delete /usr/local/Caskroom
rm: /usr/local/Caskroom: Permission denied
Warning: Failed to delete /usr/local/Cellar
rm: /usr/local/Cellar: Permission denied
==> Removing empty directories...
==> /usr/bin/sudo /usr/bin/find /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/var /usr/local/Caskroom /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks -name .DS_Store -delete
==> /usr/bin/sudo /usr/bin/find /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/var /usr/local/Caskroom /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks -depth -type d -empty -exec rmdir {} ;
==> Homebrew uninstalled!
The following possible Homebrew files were not deleted:
/usr/local/.com.apple.installer.keep
/usr/local/Frameworks/
/usr/local/Homebrew/
/usr/local/bin/
/usr/local/etc/
/usr/local/go/
/usr/local/include/
/usr/local/lib/
/usr/local/mysql -> /usr/local/mysql
/usr/local/mysql-8.0.21-macos10.15-x86_64/
/usr/local/opt/
/usr/local/sbin/
/usr/local/share/
/usr/local/var/
You may wish to remove them yourself.
我没用sudo,所以/usr/local/Caskroom和/usr/local/Cellar没有删掉,还忘记了cwd就在/usr/local/Cellar,最后还提示有一下可能的Homebrw文件没被删除,所以又手动删除了:
(venv_mac) ✘ haypin@HaypinsMBP /usr/local sudo rm -r Homebrew
然后按照官网最新的安装脚本重装Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
这是官网的安装脚本,用的国外的源,下载速度很慢,还可能失败,多执行几次就好了,国内的源在后面升级brew时很不友好啊,我这次报python3.9传参错误就是Homebrew2.4.9,既使brew update也还是2.4.9,不会升级到最新的3.2.0,所以虽然慢点,但还是想用国外的源。
换源参考:https://zhuanlan.zhihu.com/p/90508170,换了清华源后source ~/.zshrc报错:
(venv_mac) haypin@HaypinsMBP ~/cmake_tutorial source ~/.zshrc
compinit:503: no such file or directory: /usr/local/share/zsh/site-functions/_brew_cask
解决办法:https://blog.csdn.net/shentian885/article/details/115902464
然后我发现cmake官网有dmg安装包,可以安装到/Applications,就从cmake官网下载安装了,后面如果有升级的需求就直接整个rm -r /Applications/CMake.app然后下载最新的cmake-3.21.0-macos-universal.dmg安装,当然,要把路径/Applications/CMake.app/Contents/bin/加到PATH中。
被这次的brew install cmake报的错给吓怕了,以后能自己到官网下载的软件就去官网下了。