已安装,只是没有连接

注意: 我不太擅长使用 shell。

我想用 brew在优胜美地上安装 Valgrind

brew install --HEAD valgrind

到最后,我得到了一个错误与链接,所以当我试图重新安装,我得到:

警告: 已经安装了缬草头,只是没有链接

显然我已经安装好了,然后根据其他问题和答案,我试着:

brew link valgrind

这似乎解决了其他人在连接已安装的软件时遇到的问题,但这给了我一个错误:

Linking /usr/local/Cellar/valgrind/HEAD...
Error: Could not symlink lib/pkgconfig/valgrind.pc
/usr/local/lib/pkgconfig is not writable.

我也试图更新 brew,但它没有解决这个问题。如果它是不可写的,也许 sudo会给我许可,但我不想使用 sudo没有确切知道我在做什么。

发生了什么,我该怎么办?

100180 次浏览

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>

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

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

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.

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 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>

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.

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 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.