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.
Related
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'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
$ 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!
I installed MongoDB via Homebrew (following http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/) but it's not working.
Typing mongod at shell prompt gives me:
-bash: mongod: command not found
Not sure if I need to add something for Homebrew to my PATH env var?
I can see Mongo is installed under /usr/local/Cellar/mongodb – but am assuming I don't need to add everything I install via homebrew to the path? Also, assuming I can run mongod from any directory or am I actually meant to be in install directory?
When I run brew doctor I get:
Warning: You have unlinked kegs in your Cellar
Followed by a list of 3 items which includes MongoDB – but I'm not sure how I'm meant to link them?
Works perfectly
brew update
brew tap mongodb/brew
brew install mongodb-community#4.2
For latest version, check https://docs.mongodb.com/manual/release-notes/
You're getting this error because your 'brew' install failed to create the correct symlinks in /usr/local/bin. As a result, the shell can't find the mongo executables in your $PATH. You can fix this using the following steps:
Check the permissions on /usr/local/bin and make sure that you own that directory and have write permissions on it
$ ls -ld /usr/local/bin
Once you've fixed that, run 'brew link' to fix the symlinks
$ brew link mongodb
If you are on mongodb-community#4.0. You can try to reinstall with brew reinstall mongodb-community#4.0.
Then I get the following hint:
==> Caveats
mongodb-community#4.0 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have mongodb-community#4.0 first in your PATH run:
echo 'export PATH="/usr/local/opt/mongodb-community#4.0/bin:$PATH"' >> ~/.bash_profile
So you can just copy the echo command and restart your shell!
Copied from a different channel running these commands in the terminal updated the installation/configuration issues as described in OP
brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community
I faced the same problem and this solution seemed to work for me. I had previously uninstalled mongodb and reinstalled it through homebrew which gave me a bunch of problems. This solution seemed to work just fine.
brew uninstall --force mongodb
brew cleanup -s mongodb
brew cleanup --prune-prefix
brew install mongodb
It works from the directory since the sh searches the ENV path and then the cwd for a program named mongod. I have been looking around a little and it seems that the default install of MongoDB (I am not a Mac user) does not install a rc or init script for which sh to understand it's running behaviour as stated here:
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/#using-mongodb-from-homebrew-and-macports
The packages installed with Homebrew and MacPorts contain no control
scripts or interaction with the system’s process manager.
If you have configured Homebrew and MacPorts correctly, including
setting your PATH, the MongoDB applications and utilities will be
accessible from the system shell. Start the mongod process in a
terminal (for testing or development) or using a process management
tool.
So you must actually define (as you said) MongoDBs path, here is an example: https://snipt.net/sido/installing-mongodb-on-os-x/
Edit: the example is not mine. I just stole it from it's user: https://snipt.net/sido/
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.