Back

HomeBrew 安装旧版本应用

  • 通过github commit url安装历史版本
  • 通过brew extract安装历史版本

起因

最近在看cpp,用到了gettext库,编译时出错,该库当前最新版本为0.21(brew默认安装最新版本),看别人大多使用0.19.8,于是考虑使用brew安装历史版本。

过程

  • 按照brew之前的安装旧版本的方式

    1. 通过github寻找该包的仓库地址brew info gettext

      • 注:如果修改过homebrew源,可以直接前往https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/<package>.rb
    2. 查看history

    3. 找到具体版本commit

    4. 点进去,点击Raw格式,获取到地址栏地址。

      https://raw.githubusercontent.com/Homebrew/homebrew-core/d084873b35054e2d76af8aad1f4540e29a0dbbea/Formula/gettext.rb

    5. 使用brew安装

      brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/d084873b35054e2d76af8aad1f4540e29a0dbbea/Formula/gettext.rb

    6. 之前版本可以通过上述方式进行安装。

问题

  • 新版本HomeBrew使用上述方法安装会报错:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    
    /usr/local/Homebrew/Library/Homebrew/formulary.rb:277:in `load_file': Invalid usage: Installation of gettext from a GitHub commit URL is unsupported! `brew extract gettext` to a stable tap on GitHub instead. (UsageError)
    	from /usr/local/Homebrew/Library/Homebrew/formulary.rb:185:in `klass'
    	from /usr/local/Homebrew/Library/Homebrew/formulary.rb:180:in `get_formula'
    	from /usr/local/Homebrew/Library/Homebrew/formulary.rb:418:in `factory'
    	from /usr/local/Homebrew/Library/Homebrew/cli/parser.rb:633:in `block in formulae'
    	from /usr/local/Homebrew/Library/Homebrew/cli/parser.rb:629:in `map'
    	from /usr/local/Homebrew/Library/Homebrew/cli/parser.rb:629:in `formulae'
    	from /usr/local/Homebrew/Library/Homebrew/cli/parser.rb:308:in `parse'
    	from /usr/local/Homebrew/Library/Homebrew/help.rb:103:in `parser_help'
    	from /usr/local/Homebrew/Library/Homebrew/help.rb:83:in `command_help'
    	from /usr/local/Homebrew/Library/Homebrew/help.rb:64:in `help'
    	from /usr/local/Homebrew/Library/Homebrew/brew.rb:145:in `rescue in <main>'
    	from /usr/local/Homebrew/Library/Homebrew/brew.rb:143:in `<main>'
    

    大意就是:使用github一个commit url进行安装的方式不再被支持,可以使用brew extract gettext的方式。

brew extract安装

  1. 创建一个本地仓库

    brew tap-new local/homebrew

  2. 进入仓库

    cd "$(brew --repo)/Library/Taps/local/homebrew-homebrew/Formula"

  3. 创建版本

    wget https://raw.githubusercontent.com/Homebrew/homebrew-core/d084873b35054e2d76af8aad1f4540e29a0dbbea/Formula/gettext.rb -O gettext@0.19.8.1.rb

  4. 查看版本

    • brew search gettext

    • 现在就能看到我们刚刚新建的版本local/homebrew/gettext@0.19.8.1

  5. 安装该版本

    brew install gettext@0.19.8.1

Licensed under CC BY-NC-SA 4.0
持续性混吃等死...
Built with Hugo
Theme Stack designed by Jimmy