Troubles with installation of Homebrew - terminal

I am trying to install Homebrew on a fresh install of OS X Yosemite (removed old partition using disk utility and did a complete re-install, carried over no media, completed about 10 minutes ago).
Unfortunately I have closed terminal since the first time I attempted the install using:
"ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)",
as such I do not have the original error code. I used the install command as provided above, and was directed to install command line tools. This part played out fine. After command line tools installed I hit 'return' as directed, and it began 'installing home-brew'. The installation seemed to stall and then an error message was displayed.
So then I re-attempted the install by simply re running the same terminal prompt and terminal gave me this message:
"Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.",
then this it said that the installation was successful. However, I was then prompted to run brew doctor, to which I then ran and subsequently was alerted with:
"Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
Error: Failure while executing: /usr/bin/otool -L /usr/bin/install_name_tool".
I then used the prompt "brew help" to see if it would work and it did, but again trying to use brew doctor yielded: "Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
Error: Failure while executing: /usr/bin/otool -L /usr/bin/install_name_tool".
I then attempted to use the lines from https://gist.github.com/mxcl/1173223 to uninstall Homebrew. Terminal displayed a message of success. I then quit terminal, re-opened it and typed brew to which I was given a catalogue of options to which I assumed brew was not installed as I had thought.
So, I do not know what went wrong with my installation of Homebrew and if someone could educate me that would help. I would also appreciate information of how to go about uninstalling and then reinstalling Homebrew with success.
Thanks

I just came across same problem (using Yosemite), with same error message. I'm a newbie on this, so I might be doing, but what I tried seemed to be working. I think this is not an installation error, but we just have to agree the license and run via sudo.
Here are the step I took. (It's a bit redundant)
First I did "sudo brew doctor"
Then it said:
You have not agreed to the Xcode license agreements, please run
'xcodebuild -license' (for user-level acceptance) or 'sudo xcodebuild
-license' (for system-wide acceptance) from within a Terminal window to review and agree to the Xcode license agreements.
Error: Failure while executing: /usr/bin/otool -L /usr/bin/install_name_tool
So I did "xcodebuild -license"
Then it said:
Agreeing to the Xcode/iOS license requires admin privileges, please
re-run as root via sudo.
So I did "sudo xcodebuild -license"
Then it said:
You have not agreed to the Xcode license agreements. You must agree to
both license agreements below in order to use Xcode. Hit the Enter key
to view the license agreements at
'/Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf'
And then I hit enter and the MAC SDK AND XCODE AGREEMENT.
You have to read to the end to actually agree to this. So I kept hitting space to show the entire Agreenent.
At the end, it said
By typing 'agree' you are agreeing to the terms of the software
license agreements. Type 'print' to print them or anything else to
cancel, [agree, print, cancel]
Then I typed "agree" and "brew doctor," it said
Your system is ready to brew.
I hope this helps!

open you xcode tools ,and it will pop up a window to let you agree xcode license and back to term window ,it will work

Related

Homebrew install - sudo?

I am trying to install Homebrew in my terminal. It first asked me for Password which I typed in (the password I use to login to my computer) and hit enter. Then it comes up with 'Need sudo access on macOS!' - what does this mean? I am already the admin (as far as I know) as this is my personal laptop, noone else uses it.
I don't understand what else they need!
My aim is to install git but I can't even get this to install first..
Can anyone help, thanks :)
Open a new terminal session.
type sudo whoami
If it comes back with root then you have root privileges. You can also check under users and groups to see if you are an admin.
Also try running it again but using sudo first. You can also type sudo !! and that will run the previous command as sudo.
Run sudo visudo
Enter you password one last time
In the editor, search for %admin
The line probably looks like this:
%admin ALL = (ALL) ALL
Change it to this:
%admin ALL = (ALL) NOPASSWD: ALL
Save and Bob's your uncle.
If your macos account is in fact an Admin account, its password should be accepted by sudo.
See also this AskDifferent answer.
Simple solution
in the terminal type first
sudo su
Type the password
Install homebrew
So it's October 2022 and I came across the sudo messages AND I'm only running Catalina:
Go to this link: https://developer.apple.com/support/xcode/ to work out which version of Xcode is compatible with your macOS.
Sign in to your Apple Developer account and go to this page: https://developer.apple.com/download/all/. Keeping looking down the page till you come across your Xcode version but don't download Xcode just download "Command Line Tools for Xcode" with the same version number as as the compatible Xcode. These tools are a much smaller size than the Xcode file and this is really what Homebrew is looking for.
Run the downloaded installer for "Command Line Tools for Xcode".
Now run the script available on the Homebrew website: https://brew.sh, the current script is:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
This ran for me without any errors at all.
Cheers
To use a command as an admin, you need to use sudo before any command, even if you're already admin.

Macports' dropping of privileges causing Xcode licence problems

I am trying to install some ports using Macports on OS X but as soon as the installation tries to invoke the C compiler I get:
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
Context:
I have run sudo xcodebuild -license and successfully agreed to the
licence however when I run xcodebuild -license I get the same error
as above.
I am running Macports in sudo: sudo port install ghostscript but
Macports seems to drop the privileges during the installation. (Also tried using the terminal as root user but that didn't seem to help either.)
Therefore, I am seeing two options: either managing to somehow agree to the licence at my user level, or forcing Macports to retain the privileges. But so far didn't manage to do any of these.
License acceptance is stored in
/Library/Preferences/com.apple.dt.Xcode.plist,
~/Library/Preferences/com.apple.dt.Xcode.plist (MacPorts copies this file from your home on startup to support older Xcode releases that required per-user acceptance), or
~macports/Library/Preferences/com.apple.dt.Xcode.plist
Try moving these files aside if they exist and re-do the license acceptance using sudo xcodebuild -license. Try also cleaning out /var/folders/zz, the Xcode command line tools use this to cache some data that may cause this problem. If that doesn't help, check file permissions on these files (at least the first one should be -rw-r--r--, i.e. readable by everyone).
There is a way to make MacPorts build as root rather than dropping privileges, but you shouldn't do that unless absolutely necessary. The privilege separation is a safety feature to avoid misbehaving ports from wreaking havoc on your system.

"sudo xcodebuild -license" fails to cure recurring xcode license prompt

I am attempting to install Homebrew on my new Mac (OS X 10.9.5; XCode ver 6.1), and I keep getting the following error message when I run "brew doctor":
"Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo."
This message repeats several times in my terminal output, and I keep getting prompted to accept the XCode license every time I start up XCode, even though I accept the license each time.
Below is what I see in terminal:
---startOuput---
$ brew doctor
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: Git could not be found in your PATH.
Homebrew uses Git for several internal functions, and some formulae use Git
checkouts instead of stable tarballs. You may want to install Git:
brew install git
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:
easy_install
easy_install-2.7
Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile
Warning: You have not agreed to the Xcode license.
Builds will fail! Agree to the license by opening Xcode.app or running:
xcodebuild -license
---endOuput---
I've done quite a bit of web research, and it seems as if the traditional solution is to do one of two things: (i) open XCode and accept the license via the GUI or (ii) accept the license via the command line with "sudo xcodebuild -license" and follow the prompts to "accept". (See, e.g., Jetbrains; Stackoverflow; GoogleCode)
But the problem is still not resolved. I have accepted the license agreement both via the GUI and the command line by running "sudo xcodebuild -license". I have done these things several times (and quite ad nauseam), but I keep getting told that I haven't accepted the XCode user license. I've also rebooted my computer repeatedly to no avail. What's really strange is that I can't seem to find any threads discussing this unique problem -- i.e., that acceptance of the XCode license agreement doesn't seem to "stick."
This is my first stack overflow post; any help would be much appreciated.
Thank you
I had the same issue — it turned out that /Library/Preferences/ was not readable/writable.
Go to /Library/ and change the Preferences folder permissions for your user to Read & Write.

running brew commands is full of 'Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.'

This affects many other things too but in brew you may see lots of things suggesting:
'Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.'
Brew explicitly recommends you do not run it under sudo.
running brew doctor gave me useful answers to this
Provided software update is closed you may be able to agree to the license by opening Xcode.app, but I couldn't... so instead I ran:
sudo xcodebuild -license
Which if you scroll to the bottom lets you type 'agree' and then you're good to go.

Xcode is not currently available from the Software Update server

I have problems with my macport after update to OS X 10.9.
I try to follow this manual https://trac.macports.org/wiki/Migration to fix them.
But when I install Command Line Tools:
xcode-select --install
I get message
Can't install the software because it is not currently available from
the Software Update server.
Meanwhile I successfully updated my other machine to OS X 10.9. and installed command-line tools with no problems, so they must be available.
What is the problem here?
You can download the command line tools for OS X Mavericks manually from here:
https://developer.apple.com/downloads/index.action?name=for%20Xcode
For OSX 10.11 or more you can download from here https://developer.apple.com/download/more/.
(The link in the accepted answer doesn't display command line tools for El Capitan (OSX 10.11))
If you are trying this on a latest Mac OS X Mavericks, command line tools come with the Xcode 5.x
So make sure you have installed & updated Xcode to latest
after which make sure Xcode command line tools is pointed correctly using this command
xcode-select -p
Which might show some path like
/Applications/Xcode.app/Contents/Developer
Change the path to correct path using the switch command:
sudo xcode-select --switch /Library/Developer/CommandLineTools/
this should help you set it to correct path, after which you can use the same above command -p to check if it is set correctly
I faced same problem of Can't install the software because it is currently not available from the Software Update Server. You may try following steps instead to make the Software Update initiate update for the Command Line Tools.
Check if Command Line Tools Update is mentioned in your list of softwares to be updated by using following command: softwareupdate -l
If Command Line Tools Update is not mentioned in that list, then manually make it part of the list using following command which will create a temporary file: sudo touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
Verify that the list now has the Command Line Tools mentioned by running softwareupdate -l again.
Now, press Cmd+Space to initiate Mac's Spotlight Search. Search for Software Update. Start the Software Update.
That will show you following kind of dialog for installing the Command Line Tools. Install away the update and be merry. :)
Remove the temporary file created in Step 2: sudo rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress.
I deleted the command tools directory given by xcode-select -p due to npm gyp error.
xcode-select failed to install the files with the not available error.
I ran the Xcode application and the command tools installed as part of the startup.
npm worked.
However this didn't fully fix the tools. I had to use xcode-select to switch the path to the Developer directory within the Xcode application directory.
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
MacOS catalina.
I just got the same error after I upgraded to 10.14 Mojave and had to reinstall command line tools (I don't use the full Xcode IDE and wanted command line tools a la carte).
My xcode-select -p path was right, per Basav's answer, so that wasn't the issue.
I also ran sudo softwareupdate --clear-catalog per Lambda W's answer and that reset to Apple Production, but did not make a difference.
What worked was User 92's answer to visit https://developer.apple.com/download/more/.
From there I was able to download a .dmg file that had a GUI installer wizard for command line tools :)
I installed that, then I restarted terminal and everything was back to normal.
I know this is an old post but I also ran into this problem today. I found out that when I executed sudo softwareupdate -l the Command Line Tools were listed as an update, so I installed them using sudo softwareupdate -i -a.
This error can occur if you are using a software update server which doesn't host the required package.
You can check this by running
defaults read /Library/Preferences/com.apple.SoftwareUpdate
and seeing if you have an entry called CatalogURL or AppleCatalogURL
You can point back at the Apple software update server by either removing this entry or using the command
sudo softwareupdate --clear-catalog
And then run the command line tools install again.
I got the same issue on MacOS Catalina.
I think I identified the root cause: I have switched the default Apple ID account and the new one was not activated as a Developer account. When I ran the xcode-select --install command, I got the same error as stated in the issue description.
After reading this post on stackoverflow, I went on https://developer.apple.com/downloads and I was asked to accept Developers terms. I think it enabled my account as a developer one. Then, I tried to run xcode-select --install again and it worked.
The command
xcode-select --install
proposes 3 options: Get Xcode; Not Now; Install.
When I choose to get full Xcode the command finished successfully. It took a while, but this way I was able to complete all macports migration instructions.
Once you get the command line tools loaded as described by Nikos M in his excellent answer above you will need to agree to the gcc license and if you are using ruby gems you may need to link llvm-gcc as gcc-4.2.
If you do not do these the gem install will report "You have to install development tools first." after you have already installed them.
The steps are:
sudo gcc
sudo ln -s /usr/bin/llvm-gcc /usr/bin/gcc-4.2
The gcc must be run once under sudo so Apple can update their license info, you don't need an input file, it will update the license before it checks its arguments. The link is needed so that ruby 1.9 can find the compiler when building certain gems, such as the debugger. This may be fixed in ruby 2.x, but I'll cross that bridge when I get there.
I had to run Xcode.app and agree to the License Agreement
Setup: Brand new MacBook with Mavericks, then brew install and other c/l type things 'just work'.
I solved this by going to the App Store and installing Xcode.
It was a pretty large 11GB install, so this is probably overkill. But, as a last resort, it seems to have solve my issues. In the middle of the installation (well around 10GB), Mac OS told me there was an update to Command Line Tools for Xcode. Performing this installation won't fix anything until Xcode is fully installed.
Once the install is done, it should start working (after you accept the license agreement).
Command + Space
Search for Xcode
Open it and accept license
Then run again from terminal xcode-select --install
Had the same issue and was getting the same error. When i ran xcode-select -p, it gave output as /Library/Developer/CommandLineTools. So that means xcode was already installed in my system. Then i ran steps as given on this answer. After which any command which required xcode ran successfully.

Resources