Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Cannot link --overwrite #19457

Closed
Closed
@bmarkovic

Description

@bmarkovic

Hello. I cannot link overwrite (i need to remove offending existing files one by one for linking to go through).

I was trying to brew ln libpng --overwrite

I get this error:

Linking /usr/local/Cellar/libpng/1.5.14... Warning: Could not link libpng. Unlinking...

Error: Could not symlink file: /usr/local/Cellar/libpng/1.5.14/share/man/man3/libpngpf.3
/usr/local/share/man/man3/libpngpf.3 may already exist.
/usr/local/share/man/man3 may not be writable.

If I were to remove the file it would not be able to overwrite another one.

I'd like to note that I own /usr/local (I gave in to this 'advice' after first such issues with Homebrew), Also this is my brew --config

HOMEBREW_VERSION: 0.9.4
ORIGIN: https://github.com/mxcl/homebrew
HEAD: 28d48b450866f2f9fe2127b7905bcd9c511354fa
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: quad-core 64-bit sandybridge
OS X: 10.8.3-x86_64
Xcode: 4.6.2
CLT: 4.6.0.0.1.1365549073
LLVM-GCC: build 2336
Clang: 4.2 build 425
X11: 2.7.4 => /opt/X11
System Ruby: 1.8.7-358
Perl: /usr/bin/perl
Python: /usr/bin/python
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

The contents of my /etc/paths

/usr/local/bin
/usr/local/sbin
/usr/bin
/bin
/usr/sbin
/sbin

Activity

dplarson

dplarson commented on Apr 26, 2013

@dplarson
Contributor

It's possible the two files listed may have incorrect permissions even though you own /usr/local

What's the output of

ls -l /usr/local/share/man/man3/libpngpf.3

ls -l /usr/local/share/man/man3
bmarkovic

bmarkovic commented on Apr 26, 2013

@bmarkovic
Author

ls -l /usr/local/share/man/man3/libpngpf.3

lrwxr-xr-x  1 bmarkovic  wheel  55  1 Tra 13:10 /usr/local/share/man/man3/libpngpf.3 -> ../../../Cellar/libpng/1.5.13/share/man/man3/libpngpf.3

ls -l /usr/local/share/man/man3

is a directory with bunch of files ALL linking to Homebrew Cellar,
and all owned by bmarkovic:wheel permissions like the file above

edit2: Just so that I don't leave it hanging:

drwxr-xr-x   22 bmarkovic  wheel     748 20 Tra 08:13 man

edit: Btw how can I force brew to work under sudo. I just feel awful security-wise to having a user writeable binary folder in the search path regardless of whether it's /usr/local/bin or something under my home folder. And I can't for the life of me figure out why sudo is in the dog house.

mistydemeo

mistydemeo commented on Apr 26, 2013

@mistydemeo
Contributor

Is your entire homebrew install group-owned by wheel?

Btw how can I force brew to work under sudo.

As long as the brew executable is owned by root, you can run Homebrew as root. So if you want, you can sudo chown -R root:wheel /usr/local and sudo brew won't complain.

And I can't for the life of me figure out why sudo is in the dog house.

Two reasons:

  • $USER:admin is the ownership of /Applications; we chose the same ownership for /usr/local. The admin group ensures that it's only the users who have sudo permissions who can write into /usr/local.
  • Homebrew doesn't drop permissions during the install phase, so naughty makefiles can theoretically drop things in systemwide root-owned directories during the build if they choose. In practice this comes up rarely, since that would fail the build under $USER:admin ownership and we'd notice, but it's a possibility.
dplarson

dplarson commented on Apr 26, 2013

@dplarson
Contributor

Btw, the simplest "fix" for these issue might be to backup the files and directories causing the errors to another location (e.g. your desktop), then remove the files from /usr/local/ and re-try linking the upgraded version.

bmarkovic

bmarkovic commented on Apr 26, 2013

@bmarkovic
Author

Well none of the apps in /Applications can, say, override with a malicious sudo in /usr/local that can get summoned by $USER (who is a sudo-er) and get elevated permissions whereas it can't be all that complicated to keep compiled binaries in user-owned folder and then use elevated permissions only for linking to root owned /usr/local which would certainly work with all packages since that's how they expect it to be on other *nixen but whatever, it's not my main issue here, and much smarter people than me had this discussion with your chief dev and he didn't change his mind.

I have since done the following:

  1. Uninstalled Homebrew as per your instructions in the wiki here
  2. Changed ownership of /usr/local to bmarkovic:admin (can't make it worse with this anyway).
  3. Reinstalled Homebrew and am now reinstalling packages I need.

If I don't respond to this thread assume that I've solved my issue with this. Thak you everyone.

mistydemeo

mistydemeo commented on Apr 26, 2013

@mistydemeo
Contributor

I understand your concerns, and you're not the only person who prefers to sudo. I wouldn't be opposed to adding the ability to drop permissions during the install method for sudo homebrew installs.

bmarkovic

bmarkovic commented on Apr 29, 2013

@bmarkovic
Author

Wasn't able to fix the issue itself but I have resolved Homebrew to a working state by three steps above so I will close this.

locked and limited conversation to collaborators on Feb 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bmarkovic@mistydemeo@dplarson

        Issue actions

          Cannot link --overwrite · Issue #19457 · Homebrew/legacy-homebrew