2015年10月16日 星期五

[Homebrew] Install a specific version of a homebrew package/formula (運用 Homebrew 安裝特定版本的套件)



Ubuntu 和 Debian 有好用的 apt、dpkg,Fedora 和 CentOS 也有 yum、rpm,OS X 則有非內建的 Homebrew,方便到有分支專門開發維護 Linux 上可以使用的 Linuxbrew!

這邊分享較繁複的部分:安裝特定版本的套件,以安裝 2.8.4 版的 Redis 舉例。



環境

OS X:OS X El Capitan Version 10.11
Homebrew:0.9.5

執行

步驟

cd $( brew --prefix )
git log -S "2.8.4" -- Library/Formula/redis.rb
git checkout -b redis-2.8.4 [commit hash]
brew install redis
git checkout .
git checkout master
git branch -d redis-2.8.4



步驟詳解

cd $( brew --prefix )
git log -S "2.8.4" -- Library/Formula/redis.rb
會出現



git checkout -b redis-2.8.4 [commit hash]
這邊 [commit hash] 請輸入上一個指令結果中紅色的部分,至少前五碼。


brew install redis
若碰到錯誤訊息:
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory /usr/local/bin/brew: line 21: /usr/local/Library/brew.rb: Undefined error: 0

/usr/local/Library/ENV/4.3/make: /usr/local/Library/ENV/4.3/xcrun: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory

/usr/local/Library/ENV/4.3/make: line 3: /usr/local/Library/ENV/4.3/xcrun: Undefined error: 0 /bin/sh: /usr/local/Library/ENV/4.3/clang: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
是因為 Ruby 版本不同,編輯檔案將版本 1.8 改為 Current 即可。

上面三則錯誤訊息分別相關的檔案為:
/usr/local/Library/brew.rb
/usr/local/Library/ENV/4.3/xcrun
/usr/local/Library/ENV/4.3/clang

執行方式例如:
vim /usr/local/Library/brew.rb
// 第一行原始:/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
// 更改為:/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby



若碰到訊息:
Warning: No developer tools installed. You should install the Command Line Tools. Run `xcode-select --install` to install them.
照他說的,下
xcode-select --install

最後再重新
brew install redis



成功安裝完,下
redis-cli -v
確認 redis 版本是否為預期的 2.8.4。



最後,將一些冗物回復。
git checkout .
git checkout master
git branch -d redis-2.8.4



參考

StackOverflow


沒有留言:

張貼留言