brew install - permission denied (after chown -R `whoami` ) - macos

$ brew install fontconfig
Error: Permission denied - /Library/Caches/Homebrew/Formula/fontconfig.brewing
$ sudo chown -R `whoami` /usr/local
$ brew install fontconfig
Error: Permission denied - /Library/Caches/Homebrew/Formula/fontconfig.brewing
Not sure where to go from here. Ran brew doctor to fix some existing issues, but can't seem to get past this.

trojanfoe's answer helped. There was a permission issue with the Library/Logs folder that I wasn't assigned to, but somehow the Library/Caches/Homebrew folder didn't exist. So I just created that, the subfolder Formula, and changed the permission and everything installed just fine. It actually cleared up a lot of errors I was having.
Thanks everyone.
Update
#fet's one liner works great.
mkdir -p ~/Library/Caches/Homebrew/Formula

For others that are running into the error of something like
$ brew upgrade
==> Upgrading 1 outdated package, with result:
libtool 2.4.6
==> Upgrading libtool
Error: Permission denied - /usr/local/lib/libltdl.7.dylib
Make sure that your directory, in this case /usr/local/lib, has sufficient permissions for you to access it. I ran into the issue where it was only assigned to root:admin.
$ ls -la /usr/local/lib/ | grep "libltdl.7"
lrwxr-xr-x 1 username admin 43 Oct 12 2014 libltdl.7.dylib -> ../Cellar/libtool/2.4.2/lib/libltdl.7.dylib
Switched that to myusername:admin and was able to upgrade with no problems.
cd /usr/local/lib
sudo chown `whoami`:admin .
Hope that helps!

Related

How to install Terragrunt 0.19.x version on Mac book

How to Install terragrunt 0.19.x Version on Macbook?
I tried brew install terragrunt which is Downloading 0.18.x only.
Option1:
brew install terragrunt
touch: /usr/local/Homebrew/.git/FETCH_HEAD: Permission denied
fatal: Unable to create '/usr/local/Homebrew/.git/index.lock': Permission denied
fatal: Unable to create '/usr/local/Homebrew/.git/index.lock': Permission denied
error: could not lock config file .git/config: Permission denied
==> Downloading https://homebrew.bintray.com/bottles/terragrunt-0.18.3.mojave.bottle.tar.gz
Already downloaded: /Users/rohithgundala/Library/Caches/Homebrew/downloads/f494cc7ebcfadf5e2610048e6c9f937e0151ff46cf0c226d83118e6d8ba704cc--terragrunt-0.18.3.mojave.bottle.tar.gz
==> Pouring terragrunt-0.18.3.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/terragrunt/0.18.3: 3 files, 19.6MB
Option2:
# Install Terragrunt
RUN wget -q -O ${BIN_DIR}/terragrunt "https://github.com/gruntwork-io/terragrunt/releases/download/v${TERRAGRUNT_VERSION}/terragrunt_linux _amd64" \
&& chmod +x ${BIN_DIR}/terragrunt
Output:
bin/terragrunt: cannot execute binary file
Install Homebrew as described at https://brew.sh/.
Then run the following:
git clone https://github.com/cunymatthieu/tgenv.git /usr/local/Cellar/tgenv
ln -s /usr/local/Cellar/tgenv/bin/* /usr/local/bin
tgenv install 0.19.31
tfenv use 0.19.31
tgenv is a version manager for Terragrunt. https://github.com/cunymatthieu/tgenv/blob/master/README.md
It's extremely handy when you need to use a specific version or multiple versions on the same machine.
tfenv is a related tool and does the same for the terraform command: https://github.com/tfutils/tfenv
For newer versions of Mac OS the kernel is Darwin and the above answer will not work with an error like:-
zsh: exec format error
Please confirm that by running command uname -a and download the file specific to that kernel "terragrunt_darwin_amd64" for whatever version you want.
So below should work :-
wget -q -O /bin/terragrunt "https://github.com/gruntwork-io/terragrunt/releases/download/v0.xx.x/terragrunt_darwin_amd64"
chmod +x /bin/terragrunt
terragrunt -v
I found Answer for this.
wget -q -O /bin/terragrunt "https://github.com/gruntwork-io/terragrunt/releases/download/v0.xx.x/terragrunt_linux_amd64"
chmod +x /bin/terragrunt
terragrunt -v

Unable to Install postgresql on my mac os x machine via homebrew

I was trying to install the postgres through terminal on mac os. I used homebrew to install the postgres.
During the install I got following error
"Error: The brew link step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/man/man3/SPI_connect.3"
I also got error regarding initdb
"initdb: file "/usr/local/share/postgresql/postgres.bki" does not exist
This might mean you have a corrupted installation or identified
the wrong directory with the invocation option -L.
Warning: The post-install step did not complete successfully
You can try again using brew postinstall postgresql"
After the install I am not able to run any of postgres commands. I would really appreciate any help as I am new to postgres. Please, provide little explanation.
Thank You!
Not sure if this solution is the best, but so far this is the only one.
Note: I did this on a macOS environment
I have chowned the directory I wasn't allowed to write. (chown -R user/usr/local/lib/pkgconfig)
/usr/local/lib/pkgconfig` (assumed that dir should be mine anyway - since it's within /usr/local)
I ran
brew link postgres - so the links required are there
Then initdb /usr/local/var/postgres -E utf8 worked perfectly.
Running brew postinstall postgres --debug gives:
Errno::EACCES: Permission denied # dir_s_mkdir - /usr/local/var/postgres
Creating the directory manually and setting the right group worked:
cd /usr/local/var
sudo mkdir postgres
sudo chown <user> postgres
sudo chgrp admin postgres/

Installed, just not linked

Note: I'm not so good at using shell.
I was trying to install Valgrind using brew on Yosemite.
brew install --HEAD valgrind
Towards the end, I got an error having to do with linking so when I tried to reinstall, I got:
Warning: valgrind-HEAD already installed, it's just not linked
So apparently I've already installed it. Then based on other SO questions and answers, I tried:
brew link valgrind
This seemed to solve other people's problems with linking an already installed software but this gave me an error:
Linking /usr/local/Cellar/valgrind/HEAD...
Error: Could not symlink lib/pkgconfig/valgrind.pc
/usr/local/lib/pkgconfig is not writable.
I also tried to update brew but it didn't solve the issue. If it is not writable, maybe sudo would give me permission but I don't want to use sudo without knowing exactly what I am doing.
What is happening and how to I fix it?
Looks like a permission issue. I would try doing this
chmod 755 /usr/local/lib/pkgconfig
This should make that available, then try
brew link valgrind
If that doesn't work I would try doing a check on it
brew doctor
First run
brew link <package>
If it gives an error, try for an automated diagnosis
brew doctor
brew doctor gives a list of problems that could be leading to errors in installation process.
To fix problems in case of conflicting files,
run to get a list of all actions which will be performed by overwrite without actually performing them.
To list all files that would be deleted:
brew link --overwrite --dry-run <package>
followed by this run which will execute the overwrite, assuming you feel that the actions performed by overwrite will take your system to a more stable state.
To force the link and overwrite all conflicting files:
brew link --overwrite <package>
If none of above the solution works, try this.
sudo chown -R $USER:admin /usr/local
brew link <package-name>
In my case, brew doctor got it right. At some point /usr/local/lib/pkgconfig was set to be owned by root rather than my account. The prescribed remedy worked -
sudo chown -R $(whoami) /usr/local/lib/pkgconfig
I had same problem and i resolved with next solution:
Run brew doctor from Terminal to check all your errors
then run next command:
sudo chown -R $USER:admin /usr/local/bin /usr/local/etc /usr/local/sbin /usr/local/share
after run:
brew link <package_name>
Type
link valgrind
It will show an error that it can't be linked because such-and-such directory is not writable. Cool, we make it writable now. Type
sudo chmod a+w the/directory/shown/as/error
If the directory is not writable, you wont be able to change its permission and make it writable either. Sudo will make this operation possible. chmod will change the mode and will make all(a) users be able to write(w) it.
Next you will be prompted to type your system's password. After this, again type
link valgrind
and it will work this time.
Here is what I tried and it worked:
$ brew link --overwrite sdl
Linking /usr/local/Cellar/sdl/1.2.15...
Error: Could not symlink lib/pkgconfig/sdl.pc
/usr/local/lib/pkgconfig is not writable.
Looked for pkgconfig: (after chmod 750)
drwxr-xr-x 4 root wheel 136B Mar 30 2013 pkgconfig
I tried chown as below:
$ sudo chown -R avkashchauhan:admin /usr/local/lib/pkgconfig
it should look like as below:
drwxr-xr-x 4 avkashchauhan admin 136B Mar 30 2013 pkgconfig
After I tried it:
$ brew link sdl
Linking /usr/local/Cellar/sdl/1.2.15... 182 symlinks created
brew install cocoapods --build-from-source
brew link --overwrite cocoapods
The only commands that worked for me on after upgrading to MAC OS Mojave 10.14.6
I got a similar problem,
$ brew install sqlite
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
No changes to formulae.
Warning: sqlite-3.17.0 already installed, it's just not linked.
I tried to link it,
$ brew link sqlite
Warning: sqlite is keg-only and must be linked with --force
Note that doing so can interfere with building software.
Then do it by force,
$ brew link --force sqlite
Linking /usr/local/Cellar/sqlite/3.17.0... 8 symlinks created
I had same a problem about permission, but after I give my permission, still error permission. And here I do, first:
brew unlink valgrind
and then,
brew link valgrind
hope this help.
I had the similar issue. I needed to brew link carthage.
But none of answers worked for me.
I've also seen the next error for any command I tried:
Error: Could not symlink .
/usr/local/opt is not writable
Only one solution helped:
Open the Finder;
Command + Shift + G;
Pass the /usr/local path;
Create opt folder manually (that was the folder name from my error message, but in your case it can be something different, such as lib/pkgconfig in the original question, so check yours in the Terminal);
re-run your command again.

Virtualenv permission denied

After a lot of struggle with virtualenv/virtualenvwrapper I decided to remove all virtualenvs and re-install the packages.
root> su myuser
myuser> sudo pip install virtualenv
myuser> sudo pip install virtualenvwrapper
I proceeded to add this to my unix users .bashrc file.
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.7
source /usr/local/bin/virtualenvwrapper.sh
When I source .bashrc I get about 20 error lines ending with IOError: [Errno 13] Permission denied: '/root/.virtualenvs/premkproject'. I'm running out of ideas...
I have done my homework and tried every suggested solution I could find. I'm running Ubuntu 12.04.
I had the same problem and it was due to .virtualenvs having owner and group root. So the following would fix it (substituting ubuntu:ubuntu for your user and groups):
cd ~
sudo chown -R ubuntu:ubuntu .virtualenvs/
I used the recursive option as I had a problem installing a package with pip and that was due to a file lower down the hierarchy also having a permissions problem.
You never explained in which SO are you working...So if you are in Mac OS X you can easily fix it by giving eXecute permissions.
I believe Linux may face the very same problem altought I myself never got this problem under Linux.
The 'magic words' are the following :
chmod 755 <your path>/virtualenv.py

ffmpeg brew yasm

I'm trying to install ffmpeg via brew. It error I get with yasm is
"Error: You must `brew link pkg-config yasm' before ffmpeg can be installed"
When doing so I'm told that my permissions are insufficient.
"Linking /usr/local/Cellar/pkg-config/0.28... Warning: Could not link pkg-config. Unlinking...
Error: Permission denied - /usr/local/share/doc"
The permissions are -rw-rw--- . I've tried unlinking yasm package and then redoing it with no luck. Any ideas?
I figured it out.
Go to whatever directory they specify in the terminal
and then do chown <your username> . or for a subfolder chown <your username> someFolder
sometimes that does not work for all directories, so use sudo chown <your username> . and enter your password
now try to relink yasm, brew link yasm and then once that is done brew install ffmpeg should work
My /usr/local/share/doc is
drwxr-xr-x
owned by my user name and group admin. Try that.
Also try brew doctor.

Resources