Whenever I try to install packages through homebrew or pip, it gives me a permission error. (I'm using macOS Catalina)
I somewhat got pip to work by using the "sudo -H" prefix. It downloads them successfully but then when I attempt to import them in Python, it tells me the module wasn't found. Earlier today I changed the default version of Python to 3.8.2, but the same error was happening way before that.
Here's the Homebrew command I used:
brew install libyaml
Here's what it's returning:
Error: Permission denied # apply2files - /usr/local/lib/node_modules/json-server/node_modules/term-size/vendor/macos/.DS_Store
you need to check user permissions on the first /usr, /usr/local, and /usr/local/lib directories. you need rwx permissions to write content in these folder. Failing this permission on any folder will not allow you to modify content in /usr/local/lib.
you can use sudo chmod u+rwx folder_name to provide read write execute on the folders. If you want to providerwx permission to all folder inside /usr use sudo chmod u+rwx -R /usr
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.
I've already seen this post. And it didn't seem to solve my issue. Here's what I get when I try to run brew install nginx --with-passenger
Error: You must `brew link pcre' before nginx can be installed
So I then tried cd /usr/local, followed by ls -l. All of the files are mine. So I don't see the need to call sudo chown $(whoami) /usr/local/<sub-foldername> I've then tried doing brew link pcre and yet I get another error. Error: Could not symlink bin/pcregrep I'm not really sure what to do now. Any ideas?
I was able to get it working by forcing it with. brew link --overwrite pcre This would force the link and overwrite all conflicting files.
I am trying to install imagemagick on OS X Mavericks. When I run brew install imagemagick I get this output at the end:
Warning: Could not link imagemagick. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link imagemagick'
Possible conflicting files are:
/usr/local/bin/convert
/usr/local/share/man/man1/convert.1
==> Summary
I tried some of the solutions listed here (not all though), but didn't get further. I also tried brew link imagemagick, but I get:
Linking /usr/local/Cellar/imagemagick/6.8.7-7... Warning: Could not link imagemagick. Unlinking...
Error: Could not symlink file: /usr/local/Cellar/imagemagick/6.8.7-7/bin/convert
Target /usr/local/bin/convert already exists. You may need to delete it.
To force the link and overwrite all other conflicting files, do:
brew link --overwrite formula_name
To list all files that would be deleted:
brew link --overwrite --dry-run formula_name
So my question: is it safe to run brew link --overwrite imagemagick? What could go wrong if I overwrite /usr/local/bin/convert?
I had the same problem, and after a bit of investigation, I'm pretty sure that the existing /usr/local/bin/convert was installed with MacTeX, which I did not install through homebrew. Replacing it with the homebrew installed 'convert' worked fine - you might want to back up the existing files beforehand just in case though.
I'm having some trouble with brew which I'm trying to solve. When I currently run brew doctor I get the following output:
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
autoconf
libevent
Warning: Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting the PATH for example like so
echo export PATH="/usr/local/sbin:$PATH" >> ~/.bash_profile
So I went ahead and tried all the suggestions. First brew link autoconf, which results in:
Linking /usr/local/Cellar/autoconf/2.69... Warning: Could not link autoconf. Unlinking...
Error: Could not symlink file: /usr/local/Cellar/autoconf/2.69/share/emacs/site-lisp/autotest-mode.elc
Target /usr/local/share/emacs/site-lisp/autotest-mode.elc already exists. You may need to delete it.
To force the link and overwrite all other conflicting files, do:
brew link --overwrite formula_name
To list all files that would be deleted:
brew link --overwrite --dry-run formula_name
So again I tried the suggested command: brew link --overwrite autoconf:
Linking /usr/local/Cellar/autoconf/2.69... Warning: Could not link autoconf. Unlinking...
Error: Permission denied - /usr/local/share/emacs/site-lisp/autotest-mode.elc
My initial response to a permission denied is usually prepending it with sudo, which leads brew to tell me: Error: Cowardly refusing tosudo brew link`.
When trying brew link libevent I get the same results as with brew link autoconf.
Finally, I tried solving the sbin that was not found by running the suggested echo export PATH="/usr/local/sbin:$PATH" >> ~/.bash_profile. This runs without error, but when I run brew doctor again, the message still appears.
Does anybody know how I can solve these issues? All tips are welcome!
The general problem here is that autoconf and libevent are already installed on your system, and they are in your homebrew "Cellar" as well. Thus there are TWO copies of autoconf on your system, and TWO copies of libevent on your system.
What homebrew is trying to do is delete the previously install (system wide) version of these libraries, and replace all the relevant REAL files with symlinks from the homebrew Cellar. That would give homebrew full control over upgrading and managing these libraries for you. It would also give you just one copy of these libraries available in two places.
The problem is that homebrew doesn't have unix permissions to delete these REAL files, and you'll need to do it yourself. Here's how for autoconf:
$ sudo rm /usr/local/share/emacs/site-lisp/autotest-mode.elc
$ sudo chmod 777 /usr/local/share/emacs/site-lisp/
$ sudo rm -rf /usr/local/share/autoconf
$ brew link --overwrite autoconf
You should see:
Linking /usr/local/Cellar/autoconf/2.69... 21 symlinks created
UPDATE I just noticed the part about sbin. I'm not sure how this problem happened originally, but I can explain how to fix it.
The fix recommended by homebrew (ECHO ...) only takes effect when you next login to your Mac. To have this change take effect now, you have to force your terminal to re-read the .bash_profile file. Just $ source ~/.bash_profile after you run the ECHO command provided by homebrew.
Since this question is a few months old now, you probably already discovered that this error message has gone away.
Run the following commands to grant the privileges:
$ sudo chown -R $(whoami) /usr/local
Once the privileges are granted, now they have to be just linked since it is already installed:
$ brew link autoconf
$ brew link libevent
You may want to change writing permissions with chmod on /usr/local/share/emacs/site-lisp/autotest-mode.elc
After that you should get something like this:
Linking /usr/local/Cellar/autoconf/2.69... 21 symlinks created