Permissions error for homebrew 'brew update' on linux - activerecord

I've got a permission error with Homebrew ported to linux via this handy how-to:
http://blog.frameos.org/2010/11/10/mac-homebrew-ported-to-linux/comment-page-1/#comment-2208
I’ve got the same problem:
> $ brew update –verbose
>
> git checkout -q master fatal: Unable to create
> ‘/opt/homebrew/.git/index.lock’: Permission denied Error: Failure
> while executing: git checkout -q master
Tried changing the file permission on the ‘index’ file, no luck. My final goal is to be able to install freetds and tinytds on my Ubuntu server (brew install freetds) so if there's another way to do so please lemme know!

Sorry, the small tutorial was horribly broken...
In a nutshell:
sudo apt-get install build-essential
sudo mkdir /opt/homebrew
sudo chown `whoami` -R /opt/homebrew
git clone git://github.com/rubiojr/homebrew.git /opt/homebrew
Looks like you need to fix permissions when running with an unprivileged user?
chown -R `whoami` /opt/homebrew
Let me know if that helps.

Related

Cannot install homebrew packages because permission is denied

When I run brew install {package}, I get the following:
ln: /usr/local/bin/{package}: Permission denied
But if I try to use sudo brew install {package}, I get the following:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
How do I get homebrew working again?
You can fix permissions for Homebrew by running:
cd /usr/local && sudo chown -R $(whoami) bin etc include lib sbin share var Frameworks
See this answer for details: https://stackoverflow.com/a/44208097/1807667

Can't install homebrew

I have a fairly new macbook pro and I'm simply trying to install homebrew according to the directions on their site:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
However, when I run this I get the following output:
The user \u cannot be found
There was an unknown error.
This script requires the user \u to be an Administrator.
My macbook only has 1 user, which is me, the Administrator. That's who I'm logged in as on the computer.
Another thing I've tried is running the command with sudo, in which case I get the following message:
Don't run this as root!
Another thing I've tried is downloading Command Line Tools (CLT) for Xcode: xcode-select --install as I saw this suggested on Homebrew's site and elsewhere online.
After creating a new user with "Admin" privileges apart from my root account, the homebrew install command above started to run but then quit with the following error:
/usr/local/homebrew/.git: Permission denied
Failed during: git init -q
At this point I'm stuck and not sure what to do.
I was able to install Homebrew using the following steps. Note I did this on a non-root admin user account. I had to create this user account separately and give it admin access just to do this. Once I logged out of my root account and logged into the admin non-root account, I typed the following commands into terminal:
xcode-select --install
cd /usr/local/Homebrew
git init
git remote add origin https://github.com/Homebrew/brew
git fetch --all
git checkout -B master origin/master
cd /usr/local
ln -s /usr/local/Homebrew/bin/brew /usr/local/bin
I found most of these steps here:
https://github.com/Homebrew/homebrew-core/issues/5084#issuecomment-248834806
Hope this helps someone else.
Have you tried installing Xcode first?
xcode-select --install
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then see if the installation was correct with "brew doctor"
Source: https://www.howtogeek.com/211541/homebrew-for-os-x-easily-installs-desktop-apps-and-terminal-utilities/
Uninstall and reinstall reinstall Homebrew.
Run sudo chown -R $USER /usr/local and then reinstall

Installing MongoDB

I get this error when installing MongoDB on OSX, even though the second time I tried it with sudo command. Any thought?
==> Checking out tag r3.0.3
==> ./build.sh
==> /usr/local/opt/scons/bin/scons install --prefix=/usr/local/Cellar/mongodb/3.0.3 -j4 --osx-version-min=10.9 --cc=/usr/bin/clang --cxx=/usr/bin/clang++ --use-new-tools
Error: Permission denied - /usr/local/var/mongodb
Monas-MacBook-Pro:meanio mona$ sudo brew install mongodb
Password:
Error: Cowardly refusing to `sudo brew install`
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.
It's a permissions problem. The solution being:
sudo chown -R `whoami` /usr/local/var/mongodb
Per the comment:
Try creating the directory, prior to setting ownership:
sudo mkdir /usr/local/var/mongodb && sudo chown -R `whoami` /usr/local/var/mongodb
I just open /usr/local/ via finder and manually create folder with name var. Mac asked for a password. After that I successfully install MongoDB.
You shouldn't use brew with sudo. To check the overall brew sanity, run:
$ brew doctor
It will pinpoint potencial problems and it's corresponding solutions. If it really is a permission problem, as pointed by #hd1, you should fix the permissions of /usr/local/var/, where brew is trying to create the /mongodb folder.

Install git via homebrew on mac osx 10.10 results in: Error: Permission denied - /usr/local/lib/perl5/site_perl/5.18.2

Hi I just tried installing git via homebrew on my mac - something is wrong. I had the github for mac app installed, but I tried removing that. The current git version in my system is:
Nielsk#~: $ git --version
git version 1.9.3 (Apple Git-50)
This is what happens if I try to install git via homebrew:
Nielsk#~: $ brew install git
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/git-2.1.3.y
######################################################################## 100,0%
==> Pouring git-2.1.3.yosemite.bottle.tar.gz
==> Caveats
The OS X keychain credential helper has been installed to:
/usr/local/bin/git-credential-osxkeychain
The 'contrib' directory has been installed to:
/usr/local/share/git-core/contrib
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
zsh completion has been installed to:
/usr/local/share/zsh/site-functions
Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied - /usr/local/lib/perl5/site_perl/5.18.2
Error: Permission denied - /usr/local/lib/perl5/site_perl/5.18.2
How can I solve this?
I also met the same issue. I think we should change the readable permission to make sure any of the directories is readable by "all". So I tried the command: sudo chown -R $USER:admin /usr/local
and then: brew link --overwrite git It works for me, hope it will also work for you.
From High Sierra, chown of /usr/local is not allowed. However you can still change permission the sub directories in /usr/local.
In my case, I had to create Frameworks in /usr/local and sudo chown -R $(whom) Frameworks. After that follow what brew doctor says.
The better way is to create subdirectory whatever you need and run
sudo chown -R $(whoami) $(brew --prefix)/*
For those with the new El Capitan OS, you'll need to update your permissions:
Open Terminal and type the following commands:
$ sudo chown -R $(whoami):admin /usr/local
$ brew doctor
$ brew update
$ brew link --overwrite git
The above solution will work for other brew installs like node, etc. Just replace the last line if you started the installation but encountered errors during the brew installation.
I had a similar permission denied error on install of git until I cleaned things up:
$brew doctor
..... << long output of issues, so you run:
$brew prune
$brew doctor
..... << less issues now, so manually clean up
$brew update
$brew install git
Does that address your error as well?
I did what brew doctor recommended and it helped:
sudo mkdir -p /usr/local/sbin
sudo chown -R $(whoami) /usr/local/sbin
MacOS 10.14.4

Permission Error with homebrew

Whenever I try to install something with homebrew, I get this error:
Error: Permission denied - /Library/Caches/Homebrew/Formula/tmux.brewing
and I am just using the normal command
brew install tmux
Any ideas on how I can fix this?
Thanks.
sudo chown -R your_username /Library/Caches/Homebrew should do it. Possible but unlikely you'll also need to chmod -R o+w /Library/Caches/Homebrew.
If you have a multi-user Homebrew setup, consider using brewdo.
The solution posted here to a similar question worked.
Namely:
sudo chown -R $(whoami) /usr/local

Resources