天天看點

Mac下安裝thrift

  1. 首先安裝homebrew,網上有很多文章可以參考,這裡不再贅述。
  2. homebrew安裝完畢之後,使用brew install thrift指令安裝,但是……此時homebrew安裝的thrift可能不是你想要的版本,請看第三點。
  3. 如果brew中thrift不是想要的版本,可以使用如下指令,搜尋brew中包含的thrift版本:
~ brew search thrift
==> Formulae
thrift                                                             [email protected] ✔
           

   如上所示,brew中包含的thrift版本,但是此時還是不清楚具體版本。請使用如下指令進入brew在本地中的存儲位置:

~ cd $(brew --repo)
~ cd Library/Taps/homebrew/homebrew-core/Formula/
           

 其實就是github檔案在本地的clone,此時直接檢視thrift.rb 或者 [email protected]即可看到具體版本。

 其中homebrew中thrift最新版本在thrift.rb檔案中,該檔案最新位址:

  https://github.com/Homebrew/homebrew-core/blob/master/Formula/thrift.rb

 如果這兩個檔案中都不是你想要的版本,可以去homebrew對應github倉庫中查找,其中 0.9.3對應位址如下:

 https://github.com/Homebrew/homebrew-core/blob/9d524e4850651cfedd64bc0740f1379b533f607d/Formula/thrift.rb

 或者直接使用如下指令檢視本地brew包含的thrift版本:

~ brew edit [email protected]
class ThriftAT09 < Formula
  desc "Framework for scalable cross-language services development"
  homepage "https://thrift.apache.org"
  url "https://archive.apache.org/dist/thrift/0.9.3/thrift-0.9.3.tar.gz"
  sha256 "b0740a070ac09adde04d43e852ce4c320564a292f26521c46b78e0641564969e"

  bottle do
    cellar :any
    sha256 "9bf6dbb1699dd2e47ec08c0a6c45d922bfe44e39541cfa824c6d3fa0e612cbee" => :high_sierra
    sha256 "52d2ce63e41f13d81c4df4cff528d5bd25b75b09316a59e0cd7060bbb313a831" => :sierra
           

 如上圖所示,可以看到具體版本。 

 若要替換thrift.rb,使用如下指令:

~ rm thrift.rb
# download 0.9.3 thrift.rb
~ wget https://raw.githubusercontent.com/Homebrew/homebrew-core/9d524e4850651cfedd64bc0740f1379b533f607d/Formula/thrift.rb
~ brew install thrift
           

安裝完畢,若要恢複,使用如下指令:

~ git reset HEAD --hard
           

使用brew安裝完之後,出現如下提示:

[email protected] is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have [email protected] first in your PATH run:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
  export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

For pkg-config to find [email protected] you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
           

 此時需要按照上述提示資訊,把thrift路徑放在系統執行PATH後,然後重新開機Teminal即可使用。