Fixing brew doctor warnings/errors - ruby

I have recently installed Homebrew and RVM. However, when I tried to install a new version of Ruby into RVM:...
rvm install 2.2
I got the following error:
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/osx/10.9/x86_64/ruby-2.2.0.tar.bz2
Checking requirements for osx.
ERROR: '/usr/local/bin' is not writable - it is required for Homebrew, try 'brew doctor' to fix it!
Requirements installation failed with status: 1.
So I ran the doctor command to view errors and saw:
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: /usr/local/bin isn't writable.
This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.
I found the same issue with various other directories:
/Library/Caches/Homebrew
/usr/local/Cellar
/usr/local/etc
/usr/local/include
/usr/local/lib
/usr/local/lib/pkgconfig
/usr/local/opt
/usr/local/share
/usr/local/share/man
/usr/local
When I installed RVM, I did a single user install into a non admin account. This non admin account I will be using as my development account. Is this ok, or should I be developing using an admin account? I am running into all sorts of permissions type issues; eg trying to install a gem, because of write permissions failures and am now questioning what is the proper way to develop code, without being an admin, or should I be an admin?
I was going to start using chown to fix these errors ie
chown $USER -R /usr/local/bin
but, this worries me. Do I want to be changing the owner of all these system directories to my non admin account? Just want some re-assurance really before I go ahead, it just feels, wrong. (PS; is that the correct use of chown?)
I've seen other articles that suggest using sudo, but I've also seen artciles that say you shouldn't use sudo. Err-ing on the side of caution, I would rather not use sudo.
Thanks.

Most of these questions are pretty well covered by the Homebrew FAQ.
Do I want to be changing the owner of all these system directories to my non admin account?
System libraries are not installed to /usr/local. Apple doesn't include that directory on a clean install. Most likely some other installer put things there as root or another user.
I've seen other articles that suggest using sudo, but I've also seen artciles that say you shouldn't use sudo.
Homebrew should not be used with sudo, but it does assume the user is an admin and has rights to /usr/local. If you are just referring to fixing the permissions with chown, that will require sudo (and admin account).

Related

how to install readline-devel without root

Struggling with it for days...
I tries to visit the official website of readline, but did not see the devel version,
and searched many pages, just found readline-devel.rpm, and I an a root user, so I can't install it with yum.
Any help would be appreciated~
It looks like your only option is to use rpm2cpio as suggested here, here and here.
The best course of action is to request the system administrator to either install the package for you or grant you sudo rights for you to install the application.

OS X Yosemite - Vagrant: Failed to install / update plugins (ruby invalid option -H)

I've done a fresh install of OS X Yosemite and Vagrant on my Mac some days ago. The problem is, that every time when I try to update all plugins or install a vagrant plugin (vagrant-cachier), I'll get the following error:
An error occurred while installing json (1.8.2), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.2'` succeeds before bundling.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/opt/vagrant/embedded/bin/ruby extconf.rb
/opt/vagrant/embedded/bin/ruby: invalid option -H (-h will show valid options) (RuntimeError)
If I install a gem over the system's binary it works. So it seems to be a problem with the built-in vagrant binaries. I've also already installed the command line tools. My Vagrant Version is 1.7.2
I've already googled the problem for hours, but I didn't find this problem.
Did I forget anything or does anybody has a workaround for this problem?
Thanks!
Thanks for your help. I found the problem.
The problem was the path were Vagrant is installed. My SSD partition on OS X is called "Macintosh SSD" with a space in it.
I renamed it to "MacintoshSSD" and now it works fine.
The issue appears to be that the 'embedded' binary of ruby is not happy with some older code in the JSON gem. Or something... I literally know nothing about ruby other than that it is a programming language and I installed it to use compass. And now here it is again with Vagrant.
ANYWAY I moved the embedded ruby to the side, and copied OS X's built-in ruby into the vagrant embedded binaries folder.
Something like:
sudo mv /opt/vagrant/embedded/bin/ruby /opt/vagrant/embedded/bin/ruby.2.0.0.p598
sudo cp /usr/bin/ruby /opt/vagrant/embedded/bin/ruby.2.0.0.p481
sudo ln -s /opt/vagrant/embedded/bin/ruby.2.0.0.p481 /opt/vagrant/embedded/bin/ruby
sudo vagrant plugin install vagrant-vmware-fusion
Installing the 'vagrant-vmware-fusion' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vmware-fusion (3.2.1)'!
Yay.
Straight from HashiCorp... here is the troubleshooting checklist:
Hey there,
I am really sorry you are having problems installing that Vagrant plugin. We are aware of these issues, but we have not been able to narrow it down to a specific cause because it only affects a small subset of machines and we have not identified a common denominator yet.
First, please do not try and install the plugin using sudo. This can tamper with the permissions of other Vagrant plugins and cause Vagrant to error.
Second, please ensure you have the XCode Command Line Tools installed. You can install them by running:
sudo xcode-select --install
and following the on-screen prompt.
After completing those steps, many users have found success by doing the following:
Completely uninstall Vagrant
Removing the /opt/vagrant and /Applications/vagrant directories.
Remove Vagrant's storage directory (~/.vagrant.d). Warning: If you
have installed other Vagrant plugins or Vagrant plugin licenses,
they will be removed!
Reinstall Vagrant from the official Vagrant installers:
https://www.vagrantup.com/downloads.html
Install the plugin
Additionally, please ensure the following:
If there is a special character anywhere in Vagrant's path, you must
choose a different directory. This includes spaces (like in a
username or folder name) and parenthesis (like C:/Program Files
(x86)). Unfortunately there is a bug in the language in which Vagrant
is written that prohibits compiling native extensions under these
circumstances.
If you are using a Mac, please make sure you have accepted the XCode
license agreement. In some situations, native extensions will fail to
compile because XCode is prohibiting the installation due to an
unaccepted license agreement. To accept the license agreement, simply
open XCode - you will be prompted if you need to accept the
agreement.
If the problem persists after taking these steps, please provide the output of the plugin installation's debug logs.
Please let me know if you have any questions.
Best,
Seth

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

permissions for the /Library/Ruby/Gems/1.8 directory

I want to download and set octopress, and I follow the hint and type:
$cd octopress
$gem install bundler
then it shows that:
"ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/1.8 directory.
What does it mean? I don't know how to write permissions for it. What should I do?
Your question lack some basic information, I would say ;) For this kind of problem you should include at least your OS (I guess you are on mac os because of the /Library directory)
What the error says is that, as a normal user, you cannot write in the /Library directory, which is a system directory (and as such require administrator privilege).
From what I read, there is no root account on mac os by default, but maybe you can use sudo to issue a command with temporary privilege: try
sudo gem install bundler
and see if it works (it should prompt you from your password).
Otherwise, you can certainly install the program locally (in your $HOME), but as I never used mac os I can't really help you here. If the above does not work, I suggest you rephrase your question as "using gem on mac os", or something similar.

Installing in Homebrew errors

Attempting to install rvm and ruby 1.9.2
I already installed homebrew and git, but couldn't get complete updates because I kept getting permission errors. Re-installed Snow Leopard and repaired permissions.
Now this happens...
$ brew install wget
Error: Cannot write to /usr/local/Cellar
sudo chown -R $USER /usr/local
You'll have to give yourself ownership of /usr/local/ using that line right there. I had to do this myself after using the ruby one-liner at the top of the official docs to install Homebrew. Worked like a charm for me. It ought to be the only time you'll ever need to sudo with Homebrew.
I'm not sure if the ruby one-liner does this. If it did, then something else on my system took control of /usr/local since.
Edit: I completely missed this, but #samvermette didn't (see replies to my answer): if you run this command above and have something installed via homebrew that requires special user permissions, like mysql, make sure to give those permissions back (as the above command gives recursive ownership to everything inside /usr/local to you ($USER). In the case of mysql, it's…
sudo chown -RL mysql:mysql /usr/local/mysql/data
I had this issue after upgrading to Mavericks, and this page was the top search result when googling the error message. I continued searching and found this answer on stack overflow.com. Put concisely, it is:
sudo chmod a+w /usr/local/Cellar
This fixed the issue for me, and as it only changes permissions for the specific path referenced in the error message, seemed unlikely to have negative side effects with other installations.
I'm putting this answer here for anyone else who may find this page first like I did. However, credit should go to jdi.
You can allow only Admin users writing into /usr/local/?
chgrp -R admin /usr/local
chmod -R g+w /usr/local
chgrp -R admin /Library/Caches/Homebrew
chmod -R g+w /Library/Caches/Homebrew
Since that each user who belongs to Admin group, will be able to install new dependencies.
On High Sierra you need the following command cause chown will not work:
sudo chown -R $(whoami) $(brew --prefix)/*
Link:
https://github.com/Homebrew/brew/issues/3228
uninstall and re install HomeBrew that will do the trick
I suggest ensuring that the current user is a member of the group that owns /usr/local. I believe by default, that group is wheel. To make yourself a member of that group:
$ sudo dscl . append /Groups/wheel GroupMembership $USER
Although something of an inelegant hammer, it has the intended effect - enabling access to items in /usr/local that are intended only for use (read/write) by elevated members. This approach has benefits of the other above because it takes advantage of the group memberships, enabling multiple (authorized) users on the system to use homebrew.
How did you install Homebrew? Their official installation instructions include running a ruby script. That should take care of the permission issues for you.
If you don't want to run a script, there is a section of that page called "Installing to /usr/local for Developers" that explains the change in permissions needed for the /usr/local directory.
EDIT: As mentioned in the comments it's a bad idea to use sudo with homebrew, so don't use the following answer!
You can also prevent this error if you execute the command with sudo:
$ sudo brew install wget
But take care of using sudo because you can make a lot of mistakes.

Resources