2015-09-19 151 views
0

我一直試圖在我的mac上安裝Git,但每次使用$ git --version命令。無法在我的mac上安裝Git

我收到以下錯誤

xcrun:錯誤:活躍的開發路徑(「/Volumes/Xcode/Xcode.app/Contents/Developer」)不存在,使用xcode-select --switch path/to/Xcode.app指定您希望的Xcode用於命令行開發人員工具(或參見man xcode-select

我已經在我的Mac上爲iOS應用程序開發安裝了Xcode。 我不知道這個錯誤是想說什麼。

+0

是否安裝了XCode的命令行工具(https://developer.apple.com/downloads/)?請描述你如何安裝Git。我已經轉向HomeBrew作爲一名軟件包管理員,並對此感到非常滿意。如果你想嘗試一下,我在這裏有一些說明:http://steve-tarver-mac.blogspot.com/2015/05/install-homebrew.html。 –

+0

所以你做了什麼消息說,並運行'xcode-select --switch path/to/Xcode.app'?如果是這樣,發生了什麼?你應該在你的問題中描述。 – sideshowbarker

+0

@sideshowbarker我試過了,但是它說 sudo:xcode-select:command not found – Jasmeet

回答

1

所以從上述評論的討論,似乎這裏的解決方法是隻運行該命令/usr/bin/xcode-select -switch一旦與/Applications/Xcode.app/Contents/Developer/(即具有完整路徑可執行文件運行它,而艾德里安就像xpath)作爲參數:

sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer 

運行一次後,一切都應該按照預期工作。

0

您可以通過brew軟件包管理器爲Mac安裝git。我建議以這種方式安裝軟件,因爲這是在一個地方管理已安裝軟件包的好方法。例如,您可以執行brew update以獲取最新軟件包更新的列表,或登錄brew upgrade以升級通過brew安裝的所有軟件。

  1. 要安裝釀造,打開一個終端窗口,執行:

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 
    
  2. 更新您的BREW封裝,brew update

  3. 安裝混帳與brew install git
0

我已經安裝的git ,然後返回到安裝前打開的終端窗口。我嘗試運行命令git --version,並在下面引發此錯誤消息。爲了解決,我在相同的終端窗口中運行命令source /etc/profile。順便說一句,終端窗口是在我的Webstorm裏面,我的最終目標是git init併爲我的新reactjs項目設置git。快樂的編碼!

錯誤:

xcrun: error: active developer path ("/Volumes/Xcode/Xcode.app/Contents/Developer") does not exist, use \`xcode-select --switch path/to/Xcode.app\` to specify the Xcode that you wish to use for command line developer tools (or see \`man xcode-select\`)