使用 brew 安装以前版本的 chromedriver

Install a previous version of chromedriver with brew

我想用 brew 安装 chromedriver 版本 79.0.3945.36。当我尝试 运行

 brew cask install chromedriver@79.0.3945.36

它没有说 chromedriver@79.0.3945.36 is unavailable: No Cask with this name exists.

我快速检查了一下,没有发现木桶配方有版本。

安装旧版 cask 公式的 hack 方法是:

  • cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask,去引用cask的地方
  • git reset --hard c3c1b84b7a,这会将 chromedriver 设置为 v79.0.3945.36
  • git checkout -b temp,检出一个新分支,这会阻止 brew 自动刷新你的本地 master
  • brew install --cask chromedriver,这将安装您想要的版本。

之后您可以随时执行 git checkout masterbrew up 以与 homebrew-cask 的最新主控保持同步。

这是我的安装日志

==> Downloading https://chromedriver.storage.googleapis.com/79.0.3945.36/chromedriver_mac64.zip
Already downloaded: /Users/rchen/Library/Caches/Homebrew/downloads/2712e559b7e0712e196b123a7581adecc2cfdc8d8d728b01fd875b3d371e5d29--chromedriver_mac64.zip
==> Verifying SHA-256 checksum for Cask 'chromedriver'.
==> Installing Cask chromedriver
==> Linking Binary 'chromedriver' to '/usr/local/bin/chromedriver'.
  chromedriver was successfully installed!

测试日志:

$ chromedriver --version
ChromeDriver 79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945@{#614})

为了建立@chenrui 的回答,这就是我在 M1 mac 上的做法(从 93 降级到 92)。这也适用于英特尔(通过 brew --prefix)。

# Get commit which upgraded
cd "$(brew --prefix)/Library/Taps/homebrew/homebrew-cask/Casks"
git log chromedriver.rb

# Revert commit(s) which upgraded, eg ed35867f216512c9840756dce57e61f8eac26bb6
git revert ed35867f216512c9840756dce57e61f8eac26bb6

# Reinstall
brew reinstall chromedriver

# Pin version
brew pin chromedriver

# Resolve error: "chromedriver" cannot be opened because the developer cannot be verified.
xattr -d com.apple.quarantine "$(which chromedriver)"

# Later, when version no longer needs to be pinned
brew unpin chromedriver

我在下面尝试过并且成功了!

  1. 转到 /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Casks 并编辑名为 chromedriver.rb\
  2. 的文件
  3. 在第二行更新所需的 chromedriver 版本

(see - https://sites.google.com/chromium.org/driver/downloads for required version number)

  1. 从您的终端,运行 brew reinstall chromedriver
  2. 您将收到错误消息,指出 SHA 与预期值和实际值不匹配。从您的终端复制实际值并将其替换为 chromedriver.rb 文件

(Note: you may need to delete the downloaded chromedriver.zip file, follow the instruction/path location mentioned in the error message of your terminal to delete the file and then proceed to next step)

  1. 运行 再一次 brew reinstall chromedriver