"同意 xcode / ios 许可需要管理员权限,请通过 sudo 重新以 root 用户身份运行。" 当使用 GCC 时

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?

转载于:https://stackoverflow.com/questions/26197347/agreeing-to-the-xcode-ios-license-requires-admin-privileges-please-re-run-as-r

csdnceshi59
ℙℕℤℝ Similar issue : stackoverflow.com/q/32720476/1085186
接近 4 年之前 回复
csdnceshi58
Didn"t forge 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 versions
接近 4 年之前 回复
csdnceshi72
谁还没个明天 Why can't Apple's error message mention xcodebuild -license? I had this happen when running make. Recommending to run make via sudo is idiotic. Just venting.
接近 4 年之前 回复
weixin_41568131
10.24 I had the same problem with svn status. Not sure what is the relation between svn and xcode.
4 年多之前 回复
csdnceshi70
笑故挽风 This again shows, why OS X is really a great system for the power user...
接近 5 年之前 回复
weixin_41568208
北城已荒凉 I couldn't even git init without doing this.
接近 6 年之前 回复
csdnceshi51
旧行李 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.
接近 6 年之前 回复
csdnceshi60
℡Wang Yan sudo xcodebuild -license
接近 6 年之前 回复

8个回答

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.

csdnceshi52
妄徒之命 The issue to me is the separating out of "accepting the EULA" as a discrete, elevated-privilege operation; what purpose is served by this distinction? If the software presents a concern that the system administrator should be aware of, then it should be addressed at installation time. If it requires the end-user to accept an agreement for legal purposes, then it should be addressed in user space.
接近 5 年之前 回复
csdnceshi68
local-host If you don't like it then run the Xcode IDE. That prompts you to go accept the license agreement on the site, by entering your credentials there. I guess Apple should build a command line tool that prompts you to enter your developer program agent license credentials in the command line. Fact is, accepting the license agreement does require a higher level of privilege. Using sudo to satisfy the requirements does seem a little strange, to be sure.
接近 5 年之前 回复
csdnceshi73
喵-见缝插针 This also works if you get the "Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo." message while installing Browsersync with npm install.
接近 5 年之前 回复
csdnceshi72
谁还没个明天 XCode is kind of complex software bundle which is used for complex things. No warranty for edge cases is a thing they always would want to be signed. IIRC command line tools which is essentially required (not the whole XCode) does not ask for EULA but not as easy to get and install.
接近 5 年之前 回复
csdnceshi75
衫裤跑路 The license acceptance requiring advanced privileges is so that all users on the mac can now use xcode. Accept it once, accept it for all. Correct me if I'm wrong here.
接近 5 年之前 回复
csdnceshi66
必承其重 | 欲带皇冠 Yes, you will be responsible for what someone does with your laptop. Or your car. Or your gun. If someone shoots someone with your gun, you have liability unless you can prove they stole it and before they stole it you took reasonable preventative measures. Basically, you're arguing that XCode doesn't NEED you to sign their EULA via an elevated permissions check and gun salesmen shouldn't NEED to photo copy your driver's license before you buy one of their guns.
接近 5 年之前 回复
weixin_41568196
撒拉嘿哟木头 Yeah, I know all that. However I use different words to describe it. Like that: It is unreasonable that Apple asks admin privileges to get and record a user consent. Both from the point that It is not trustworthy (any app can make a window like that and time it to Xcode start) and legally questionable (as it seems to bind me for actions of all future users logging into the system). Bad design. Neither Apple nor a user NEED to have the application engineered in a way to demand admin privileges after install is over.
接近 5 年之前 回复
csdnceshi66
必承其重 | 欲带皇冠 You don't need admin privileges to run Xcode or git. You need admin privileges to agree to the terms of the Xcode EULA in order to use its applications--which git does (and you did when you installed the application). Privilege escalation here is akin to sites asking for the 3-4 digit security code on the back of your credit card. After agreeing, you don't need admin privileges anymore.
接近 5 年之前 回复
weixin_41568196
撒拉嘿哟木头 running Xcode should have NOTHING to do with root privileges, whatever excuse there is. It is proper to expect Xcode to be a userland application. Unnecessary root privileges dampen user vigilance and help exploits' proliferation in general. Even if some hardware development or push component wants admin privileges, it should be that component, not the whole dev environment, which requests privileges. Crucially, devs should be able to grant AND revoke those privileges at any point of time. The way it works now looks like a lazy way to architect Xcode on Apple's behalf.
接近 5 年之前 回复
csdnceshi80
胖鸭 Installing new software / new versions of software often requires you to enter your user password. When you run the new compiler, you hit that wall.
接近 5 年之前 回复
csdnceshi52
妄徒之命 Why does this require root, and why isn't anyone bothered by that fact?
大约 5 年之前 回复
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
csdnceshi60
℡Wang Yan If you are scripting solutions for environments that you control you can also throw in the accept parameter sudo xcodebuild -license accept.
接近 5 年之前 回复
csdnceshi52
妄徒之命 The best answer! it works like a charm.
接近 5 年之前 回复
weixin_41568196
撒拉嘿哟木头 Although a preferred way to agree to the term, this option did not work for me since there was no place in the CLI document were one or sudo can agree to the terms.
大约 5 年之前 回复
csdnceshi68
local-host Maintaining Apple build servers with configuration management and provisioning is not exactly easy, when packages like Xcode and Java JDK requires you to manually accept a license.
大约 5 年之前 回复
csdnceshi57
perhaps? There should only be one dash @dan-klasson: -license NOT --license
大约 5 年之前 回复
csdnceshi65
larry*wei I get: invalid option --license
大约 5 年之前 回复
csdnceshi80
胖鸭 This is elegant. Although I used the other method here, I would actually prefer this one if I saw it first.
5 年多之前 回复

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.

csdnceshi74
7*4 You can just press q to quit and agree if not inclined to read it.
接近 5 年之前 回复
csdnceshi64
游.程 Yeah I was running git clone on a machine I hadn't used in a minute.
接近 5 年之前 回复

Opening XCode and accepting the license fixes the issue.

csdnceshi75
衫裤跑路 I've just hit one after upgrading Xcode to v7.0 etc. and got weird errors considering everything was working prior to the upgrade running Android Studio. This answer worked for me.
大约 5 年之前 回复

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.

csdnceshi73
喵-见缝插针 It works, but may not be too apparent to users (like myself) who mainly use tools via the command line instead of the desktop. Would be good if there were some text in Terminal altering users to this.
5 年多之前 回复

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

Follow these steps:

  1. Open Terminal.
  2. Enter this command: sudo xcodebuild --license.
  3. Enter system password.
  4. Agree to the license.
csdnceshi80
胖鸭 The flag should only use one dash, i.e., sudo xcodebuild -license.
接近 4 年之前 回复

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.!!

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐