573

I just upgraded from Yosemite to El Capitan (and replicated the problem upgrading from El Capitan to Sierra), and when I try to type for example git status inside a terminal, I get the following error:

xcrun: error: invalid active developer path
 (/Library/Developer/CommandLineTools), missing xcrun at:
 /Library/Developer/CommandLineTools/usr/bin/xcrun

I don't have Xcode installed, never did. Anyone have a solution?

Boji
  • 118
  • 8
rista404
  • 7,639
  • 2
  • 18
  • 20
  • What does "which git" tell you? ...and maybe "file \`which git\`"? – Phillip Mills Oct 01 '15 at 17:32
  • `which git` responds to `/usr/bin/git`, and "file `which git`" to `/usr/bin/git: Mach-O 64-bit executable x86_64` – rista404 Oct 01 '15 at 17:35
  • 1
    That sounds good. Sorry, I don't know how xcrun is getting into this. – Phillip Mills Oct 01 '15 at 17:39
  • 1
    I had some similar problems, turns out was related to accepting the license agreement ( during the upgrade I was presented with the license dialogue but it wouldn't respond to clicks and I had to restart) once it was running again I had to start Xcode to accept the license. – TygerKrash Oct 30 '15 at 09:32
  • I am getting error in terminal "xcrun: error: active developer path ("/Applications/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`)" on 10.11.5 how to fix? – Avijit Nagare Jul 12 '16 at 11:05
  • Possible duplicate of [Command Line Tools bash (git) not working - macOS Sierra final release candidate](http://stackoverflow.com/questions/39484218/command-line-tools-bash-git-not-working-macos-sierra-final-release-candidate) – JayRizzo Mar 28 '17 at 01:13
  • I've had to run the same command after upgrading to macOS High Sierra – diegoiglesias Sep 25 '17 at 22:42
  • Answer for macOS **Catalina** in another thread here: https://stackoverflow.com/a/58801314/7613994 – arielkaluzhny Dec 26 '19 at 17:05
  • I had to run: `brew install --cask xcodes` since I'm using homebrew. After this I ran `brew outdated` and the message dissapeared – Timothy Nov 16 '22 at 17:24
  • `which git` gives `/usr/bin/git`. So in effect why do a heavy xcode installation if all we need is git. Why is git not running without xcode? – Lazarus Thurston Jan 05 '23 at 11:35

16 Answers16

1147

Found the fix for the problem here.

xcode-select --install

This will bring up a prompt to install the necessary command line tools.

Hannele
  • 9,301
  • 6
  • 48
  • 68
cuadraman
  • 14,964
  • 7
  • 27
  • 32
  • 5
    Worked for me. Had this issue after upgrade to El Captain – gerrymcdev Oct 05 '15 at 20:08
  • 23
    @PascalvKooten I had the same "Finding software" problem. The only way I was able to fix it was to [download the `.dmg`](https://developer.apple.com/downloads/) and manually install it. – ESultanik Oct 22 '15 at 20:33
  • 2
    @PascalvKooten I had the same issue. Just follow the ESultanik's advice and install the DMG, it fixed the problem immediately – s g Oct 22 '15 at 21:23
  • @Everyone else, however I was able to run `xcode-select --install` without the "Finding software" message it still didn't work. Use the .dmg as suggested (Command Line Tools OS X 10.11 for Xcode 7.2) – Ben Fransen Dec 14 '15 at 20:13
  • 1
    I am getting error in terminal "xcrun: error: active developer path ("/Applications/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`)" on 10.11.5 how to fix? – Avijit Nagare Jul 12 '16 at 11:04
  • 95
    This issue just popped up after upgrade to Mac OS sierra.! – Sreejith Menon Sep 20 '16 at 23:04
  • 1
    Fixed on macOS Sierra. Thanks – w3debugger Nov 26 '16 at 11:43
  • 2
    This solution dit not help me. But after I tried `xcode-select --reset` and it helped! – akozin Dec 30 '16 at 20:15
  • 1
    @SreejithMenon Yup and FWIW the fix above does *not* install xcode automatically. Only the dev tools. – Karl Pokus Feb 25 '17 at 13:35
  • For posterity: if you see this error with `git pull` but not with `git status` and are using a remote server that is running OS X, the problem may be on the remote rather on the local. In this case, git does NOT make it obvious if the error is coming from the server or from local. – mirth23 May 15 '17 at 14:59
  • Not only did I have to install xcode but I also had to add my keys: ssh-add -K to get this to work – kbrinner Jul 31 '17 at 15:54
  • 27
    I've just upgraded to High Sierra and the solution is still valid. – Gustavo Straube Sep 29 '17 at 11:02
  • If anyone runs into @PascalvKooten 's problem, my monkey brain told me to run `xcode-select --install` again even though it said it was "Finding Software"... and that worked. Yay? – bananabanana Nov 13 '17 at 23:41
  • I upgraded to macOS High Sierra and ran into this issue. `xcode-select --install` worked for me. Thanks!! – RC_02 Nov 24 '17 at 16:29
  • Regarding the "Finding Software" hanging problem on High Sierra, apparently it can be caused by not having your laptop power plugged in. :P – dunstantom Jan 11 '18 at 18:52
  • 1
    The issue appeared when installing macOS Mojave (Version 10.14 Beta (18A326g)) & was fixed with this solution. – PDK Jul 04 '18 at 12:57
  • Worked for me. I got the issue after updating into Black background – Manas Gond Oct 26 '18 at 07:14
  • 1
    The problem happens after upgrading to Mojave :( too and this solution still helps for that upgrade :) – mcvkr Oct 29 '18 at 15:26
  • 1
    I Tried with macOS Catalina still working! thanks a lot! – Felipe Valdivia Jun 10 '19 at 01:28
  • @ESultanik solved my issue. My issue was caused by remove and reinstall xcode. So I think xcode-select install is not working on this case. – kakadais Nov 04 '20 at 07:16
  • Worked for me. Had this issue after the latest upgrade – Rajesh Kharatmol May 02 '23 at 04:53
91

If you have issues with the xcode-select --install command; e.g. I kept getting a network problem timeout, then try downloading the dmg at developer.apple.com/downloads (Command line tools OS X 10.11) for Xcode 7.1

Robert Siemer
  • 32,405
  • 11
  • 84
  • 94
Ryan Heitner
  • 13,119
  • 6
  • 77
  • 119
  • 2
    A better answer IMO, since I prefer the ~400 MB footprint of the command line tools to the (last time I installed) multi GB Xcode. – jwd630 Feb 04 '16 at 21:32
  • I stand corrected. Where did I get the idea that it did? Perhaps that the dialog has a "Get XCode" choice and maybe I clicked that back in the Mountain Lion day. Some time or other I got all of XCode when all I wanted was the command line tools. – jwd630 Oct 05 '16 at 14:12
  • I had this problem, and it fixed itself just by opening xcode and trying again. Then it added an "update" to the App Store, which is the command line tools package. – MrFusion Oct 18 '16 at 16:00
15

In macOS 10.14 this issue may also occur if you have two or more versions installed. If you like xCode GUI you can do it by going into preferences - CMD + ,, selecting Locations tab and choosing version of Command Line Tools. Please refer to the attached print screen.

enter image description here

grzebyk
  • 1,024
  • 1
  • 15
  • 26
12

I tried the solution xcode-select --install but it don't help me, I update from Sierra to High and happened this, my solution:

sudo xcode-select --reset
Cristofer Fuentes
  • 411
  • 1
  • 6
  • 16
7

Reassigning the path Xcode is configured with worked for me.

sudo xcode-select -switch /Applications/Xcode.app

You'll then likely be prompted (after trying a command) to agree to the license agreement.

tristen
  • 4,605
  • 4
  • 24
  • 19
5

I had the same issue after upgrading to macOS Catalina. This didn't work for me:

xcode-select --install

Downloading and installing Command Line Tools for Xcode 12 did it!

enter image description here

Maikel Ruiz
  • 1,342
  • 2
  • 15
  • 25
3

For me, after I've removed Xcode, I have to switch active developer path as follows: sudo xcode-select -s /

Son Nguyen
  • 195
  • 1
  • 10
3

For Mojave

Uninstall Any old version of Command Line Tools:

sudo rm -rf /Library/Developer/CommandLineTools

Download and Install Command Line Tools 10.14 Mojave.

Mihai Chelaru
  • 7,614
  • 14
  • 45
  • 51
2

I just updated to High Sierra and I couldn't just run xcode-select --install. First, I had to actually install xcode from the app store. Then I ran xcode-select --install. Then I had to run sudo xcodebuild -license, agree to the terms, then I could finally run git commands again.

ProGrammar
  • 298
  • 4
  • 17
2

Updated to High Sierra 10.13.2

xcode-select --install ALONE did not work for me.

  1. Download X-code from app store
  2. $xcode-select --install
    a. May need to update after install using softwareupdate in command line. $sudo softwareupdate -i "Command Line Tools (macOS High Sierra version 10.13) for Xcode-9.1"

  3. $sudo xcodebuild -license

1

For those also having issues with heroku command line tools after upgrading, I also had to do the following in my terminal:

xcode-select --install 
brew install heroku/brew/heroku
brew link --overwrite heroku

It seems the upgrade to High Sierra messed with my symlinks in addition to forcing me to reinstall xcode tools. I kept getting 'not a directory' errors:

▸ stat /Users/mattymc/.local/share/heroku/client/bin/heroku: not a directory  
▸ fork/exec /Users/mattmcinnis/.local/share/heroku/client/bin/heroku: not a directory 

Hope that saves someone an hour :)

Matt
  • 5,800
  • 1
  • 44
  • 40
1

After update to macOS 10.13.3

After updating do macOS 10.13, I had to install "Command Line Tools (macOS 10.13) for Xcode 9.3" downloaded from https://developer.apple.com/download/more/

Oleksii Kyslytsyn
  • 2,458
  • 2
  • 27
  • 43
1

I upgraded mac os to macOS High Sierra - 10.13.3 and faced a similar issue while trying to install watchman (with command - brew install watchman).

ran the command: xcode-select --install, then ran "brew install watchman" - Everything works fine!

1

For the most recent version Mojave version 10.14.1, I use

solved by downloaded from https://developer.apple.com/download/more/ " login by apple id, and download

Command line tool newest stable version.dmg

That makes everything work

the old answer

xcode-select --install

doesn't work for me.

Flora PJ Li
  • 801
  • 1
  • 8
  • 9
  • 1
    This solved the issue for me. Note, the issue I had when running `xcode-select --install` was a popup about not being able to contact the update server. As of writing this, the only download in the link mentioned above for Mojave users is a beta titled "Command Line Tools (macOS 10.14) for XCode 10.1 Beta 2" – roundtheworld Nov 02 '18 at 21:41
0
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer

Work for me.

frankkai
  • 145
  • 1
  • 2
  • 9
-1

Even if you do xcode-select --install it was not fixing that for me as it showed some network error. The problem was that it could not connect to the app store. I did the following to fix it.

  1. Open keystore
  2. Go to system root and select certificates.
  3. Open digicert high assurance EV.
  4. Expand the trust section, mark it as never trust.
  5. Restart system now repeat step 1, 2, 3. and mark the trust policy as back to use system defaults.

Your app store should work now and you should be able to run xcode-select --install

Shubham Aggarwal
  • 353
  • 2
  • 16
  • 1
    Thanks for the answer. It might benefit with some explanation why you tried this and why it would work. – Pranab Mar 06 '19 at 03:21
  • It is already written in the first line. The above solutions were not working for me. So after some googling I tried this. No need for extra expatiation – Shubham Aggarwal Mar 06 '19 at 03:55