mac使用brew安装指定版本的 protoc

前几天由于执行了brew update 命令系统的某些命令跟着升级到了新版本,导致protoc 命令和项目依赖的版本不一致,新版本已经到了libprotoc 3.21.11 不是原来的libprotoc 3.21.9 ,如果不能降回原来的版本那么后续开发中将引入很多冲突,因此只能降低版本重新安装; 关于降低版本通过命令行加版本的方式尝试后因为版本对不上,不出其然失败了; brew install protoc@v3.21.9 提示如下: Running brew update --auto-update… Warning: No available formula with the name “protoc@v3.21.9”. Did you mean protobuf@3.6? ==> Searching for similarly named formulae and casks… ==> Formulae protobuf@3.6

To install protobuf@3.6, run: brew install protobuf@3.6

后来找到如下方法,到brew.sh 搜要安装的包,看到下面的提示,点击protobuf.rb 对应的链接 然后找到历史版本 下载后安装; Formula code: protobuf.rb on GitHub 进入页面点击history, 找到你要回退的版本,然后下载对应这个版本的protobuf.rb 这个是是下载的路径: https://raw.githubusercontent.com/Homebrew/homebrew-core/b89ad43b8f71daa8455b71b35a316abc549f0057/Formula/protobuf.rb 然后重新执行 ➜ Desktop brew install ./protobuf.rb Error: Failed to load cask: ./protobuf.rb Cask ‘protobuf’ is unreadable: wrong constant name #Class:0x000000013e22eb80 Warning: Treating ./protobuf.rb as a formula. ==> Fetching protobuf ==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/protobuf-21 Already downloaded: /Users/qimao/Library/Caches/Homebrew/downloads/8f3f196f67f26495072bfd456cca54da9880d00e10b0b34b9fb493609f12a3c9–protobuf-21.9.arm64_monterey.bottle.tar.gz Warning: protobuf 21.12 is available and more recent than version 21.9. ==> Pouring protobuf-21.9.arm64_monterey.bottle.tar.gz ==> Caveats Emacs Lisp files have been installed to: /opt/homebrew/share/emacs/site-lisp/protobuf ==> Summary 🍺 /opt/homebrew/Cellar/protobuf/21.9: 279 files, 19.2MB ==> Running brew cleanup protobuf… Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW_NO_ENV_HINTS (see man brew). Removing: /Users/qimao/Library/Caches/Homebrew/protobuf–21.12.arm64_monterey.bottle.1.tar.gz… (2.5MB) Removing: /Users/qimao/Library/Caches/Homebrew/protobuf–21.9.arm64_monterey.bottle.tar.gz… (4.9MB) Warning: Calling plist_options is deprecated! Use service.require_root instead. Please report this issue to the wenjunxiao/brew tap (not Homebrew/brew or Homebrew/homebrew-core), or even better, submit a PR to fix it: /opt/homebrew/Library/Taps/wenjunxiao/homebrew-brew/Formula/docker-connector.rb:38

安装成功后再次查看protoc版本,即可看到我们已经回退到指定版本; ➜ Desktop protoc –version libprotoc 3.21.9 参考1:https://makeoptim.com/tool/brew-install-specific-version/ 参考2: https://juejin.cn/post/7179202980191666233

本文链接:参与评论 »

--EOF--

提醒:本文最后更新于 533 天前,文中所描述的信息可能已发生改变,请谨慎使用。

Comments