通过自制软件安装特定版本的 R

Install specific version of R via homebrew

我已经在 macOS 中通过 Home-brew 安装了 R:

brew install R

不过现在,我需要切换版本并安装特定的 R 版本。出于这个原因,我尝试通过以下两种方式安装 R-3.5.2,但没有成功:

brew install R-3.5.2
brew install R@3.5.2

这是我得到的:

Error: No available formula with the name "r@3.5.2" 
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.

你有什么想法吗? 谢谢:)

免责声明:我没有 Mac 可用于测试。

Here you can find a quite useful tutorial on how to install old versions via homebrew, here是另一个。

对于 R 这意味着:

git clone https://github.com/Homebrew/homebrew-core.git
cd homebrew-core/
git log master -- Formula/r.rb

为 R 3.5.2 生成以下提交:

commit e66b3a288ee5e68c3c04e95705b7311c9f76bdf2
Author: ...
Date:   Sun Jan 13 10:59:16 2019 +0000

    r: update 3.5.2_2 bottle.

commit a2ced14fabb30732b2b6f22919105ac66085e78c
Author: ...
Date:   Tue Jan 8 10:36:41 2019 +0100

    r: revision for readline

commit 61c60b0c4c237a0ada3ab8b83b934566b101ee67
Author: ...
Date:   Sat Jan 5 04:06:37 2019 +0000

    r: update 3.5.2_1 bottle.

commit f9325e5e63ba812d1a2d5fd405811e313f782ff1
Author: ...
Date:   Fri Jan 4 17:36:34 2019 +0100

    r: build with openblas

commit 70aca0ac8f83459ff1ce18c1ea3f462b49434eb2
Author: ...
Date:   Fri Dec 21 06:48:02 2018 +0000

    r: update 3.5.2 bottle.

commit d344d5b57d0c8b0bf0ef6b3052e6bed551b37b47
Author: ...
Date:   Fri Dec 21 14:31:14 2018 +0800

    r 3.5.2

    Closes #35321.

作为替代方案,您可以通过 URL 搜索提交(请参阅 this 评论):

https://github.com/Homebrew/homebrew-core/search?q=r%203.5.2&type=commits


因此,您应该能够通过(最新的 R 3.5.2 提交)安装 R 3.5.2:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/e66b3a288ee5e68c3c04e95705b7311c9f76bdf2/Formula/r.rb

或:

brew install https://github.com/Homebrew/homebrew-core/raw/e66b3a2/Formula/r.rb

brew switchbrew pin 中提到的 article 可能也很有趣。