Git is broken: “Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo”

buggitxcode

My install of git seems to be broken, and it looks like somehow my Developer Tools are broken.

When I try to run git, I get this error. This happens both with /usr/bin/git and /opt/local/bin/git (from MacPorts):

cook47@rcmac (RC_bash_lib (master)): /usr/bin/git pull     
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.

fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

I have run Xcode and agreed to the license. I tried running xcode-select --install and got another error:

cook47-a@rcmac (current_projects): sudo xcode-select --install
Password:
xcode-select: error: no developer tools were found, and no install could be requested (perhaps no UI is present), please install manually from 'developer.apple.com'.

The remote repository is not a problem;
After googling this error, I downloaded the commandlinetools installer from Apple for OS X 10.9.5 and XCode 6.2. It installed successfully. However, git still is broken and xcode-select --install still gives the same errors.

I also tried xcodebuild -license and it does prompt me to agree to the agreement but after agreeing, no change. Still broken.

This has me completely stumped. This was working yesterday! I work in a government environment where it's possible an update changed something, so I cannot be sure exactly what might have changed.

Anyone know how I can get git working again? I tried nuking and reinstalling Xcode and the Command Line tools but to no avail. git from MacPorts and /usr/bin/git are both giving the same error message.

Best Answer

OK, I found the problem: the message was coming from the remote git server, not the client side. I ran sudo xcodebuild -license on the server side (where the repo is located and the git server is running) and the problem went away. Sigh.