Installed, just not linked

MacosHomebrew

Macos Problem Overview


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?

Macos Solutions


Solution 1 - Macos

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

Solution 2 - Macos

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>

Solution 3 - Macos

If none of above the solution works, try this.

sudo chown -R $USER:admin /usr/local
brew link <package-name>

Solution 4 - Macos

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

Solution 5 - Macos

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>

Solution 6 - Macos

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

Solution 7 - Macos

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.

Solution 8 - Macos

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

Solution 9 - Macos

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.

Solution 10 - Macos

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

Solution 11 - Macos

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:

  1. Open the Finder;
  2. Command + Shift + G;
  3. Pass the /usr/local path;
  4. 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);
  5. re-run your command again.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionaanrvView Question on Stackoverflow
Solution 1 - MacosGann14View Answer on Stackoverflow
Solution 2 - MacosVinay VemulaView Answer on Stackoverflow
Solution 3 - MacosHarshitView Answer on Stackoverflow
Solution 4 - MacosPedro JiménezView Answer on Stackoverflow
Solution 5 - MacosB.KleoView Answer on Stackoverflow
Solution 6 - MacosAvkashChauhanView Answer on Stackoverflow
Solution 7 - MacosmonkSinhaView Answer on Stackoverflow
Solution 8 - MacosX. LView Answer on Stackoverflow
Solution 9 - MacosmbdrianView Answer on Stackoverflow
Solution 10 - MacosNaishtaView Answer on Stackoverflow
Solution 11 - MacosnomnomView Answer on Stackoverflow