ChatGPT解决这个技术问题 Extra ChatGPT

Command Line Tools not working - OS X El Capitan, Sierra, High Sierra, Mojave

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?

What does "which git" tell you? ...and maybe "file `which git`"?
which git responds to /usr/bin/git, and "file which git" to /usr/bin/git: Mach-O 64-bit executable x86_64
That sounds good. Sorry, I don't know how xcrun is getting into this.
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.
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?

H
Hannele

Found the fix for the problem here.

xcode-select --install

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


Worked for me. Had this issue after upgrade to El Captain
@PascalvKooten I had the same "Finding software" problem. The only way I was able to fix it was to download the .dmg and manually install it.
@PascalvKooten I had the same issue. Just follow the ESultanik's advice and install the DMG, it fixed the problem immediately
This issue just popped up after upgrade to Mac OS sierra.!
I've just upgraded to High Sierra and the solution is still valid.
R
Robert Siemer

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


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.
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.
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.
g
grzebyk

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.

https://i.stack.imgur.com/j1nxw.png


This worked for me when I upgraded mac os to Mojave.
It works for me. In my case, I unistalled XCode and installed XCode Beta, after that command line tools didn't work anymore. So, with this solution, it works. Thks.
This is the only thing that worked for me. It was not set at all in my case.
C
Cristofer Fuentes

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

t
tristen

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.


This saves a lot of time for me. Thanks
M
Maikel Ruiz

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!

https://i.stack.imgur.com/eliYM.png


S
Son Nguyen

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


P
ProGrammar

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.


V
Viktor Nikitenko

Updated to High Sierra 10.13.2

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

Download X-code from app store $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" $sudo xcodebuild -license


M
Mihai Chelaru

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.


M
Matt

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 :)


O
Oleksii Kyslytsyn

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/


S
Shiyas Cholamukhath

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!


F
Flora PJ Li

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.


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"
f
frankkai
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer

Work for me.


S
Shubham Aggarwal

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.

Open keystore Go to system root and select certificates. Open digicert high assurance EV. Expand the trust section, mark it as never trust. 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


Thanks for the answer. It might benefit with some explanation why you tried this and why it would work.
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