492
votes

While attempting to compile my C program, running the following command:

gcc pthread.c -o pthread

Returns:

Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.

and my code does not compile.

Why is this happening and how can I fix this problem?

11
sudo xcodebuild -licenseAndy Barbour
Actually I think the comment of @Andy Barbour is the best answer since the issue can be resolved within the terminal this way. Andy: if you create an answer, I will vote for it.rexford
I couldn't even git init without doing this.ruffin
This again shows, why OS X is really a great system for the power user...Lukas
this answer to a newer, similar question shows how to agree in a fully automated fashion: sudo xcodebuild -license accept - which works on macOS Sierra here, but might not work on earlier versionsssc

11 Answers

809
votes

Open up Xcode, and accept the new user agreement. This was happening because a new version of Xcode was downloaded and the new agreement was not accepted.

559
votes
sudo xcodebuild -license

will take care of it with no trouble on the command line. Note that you'll have to manually scroll through the license, and agree to its terms at the end, unless you add "accept" to the command line :

sudo xcodebuild -license accept
114
votes

Got stuck as I was trying to a go get ... I think it was related to git. Here is how was able to fix it ...

  1. I entered the following in terminal:

    sudo xcodebuild -license
    
  2. This will open the agreement. Go all the way to end and type "agree".

That takes care of go get issues.

It was quite interesting how unrelated things were.

27
votes

Opening XCode and accepting the license fixes the issue.

15
votes

You don't need to fiddle around with any command :)

Once the XCode is updated, open the Xcode IDE program. Please accept terms and conditions.

You are all set to go :))

7
votes

Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.

A new version of OSX or XCode was installed and Apple wants you to agree to their Terms and Conditions. So just launch Xcode and "Agree" to them.

5
votes

Follow these steps:

  1. Open Terminal.
  2. Enter this command: sudo xcodebuild --license.
  3. Enter system password.
  4. Agree to the license.
5
votes

I had the same issue, after accepting the license launching XCode or running sudo xcodebuild -license accept i had to restart my Mac – otherwise it did not worked.

3
votes

I had the same issue when I tried to use git.

It is possible to install git without it. And I doubt that gcc on mac is truly dependent on XCode. And I don't want to use root to accept something unless I'm sure I need it.

I uninstalled XCode by navigating to the applications folder and dragging XCode to the trash.

Now my git commands work as usual. I'll re-install XCode if/when I truly need it.

2
votes

I'm facing the same issue.

The issue because of X-Code.

Solution: 1. Open X-code and accept user agreement (T&C). or 2. Restart your MAC, It will resolve automatically.

0
votes

If you have similar issues in Intellij do as others said above me :

  1. Open Terminal.
  2. Enter this command: sudo xcodebuild --license.
  3. Enter system password.
  4. Go to the end of file: Press space(button) to do that.
  5. Type 'Agree' to the license.

And you are done.!!