Formula built in, but not symlinked every time I install #12778

Closed
henshinger opened this Issue Jun 12, 2012 · 23 comments

Comments

Projects
None yet
7 participants

Every time I brew install, I get something like this
Error: The linking step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link llvm'

Also, this is what brew doctor gives me

 Error: You have Macports or Fink installed.
This can cause trouble. You don't have to uninstall them, but you may like to
try temporarily moving them away, eg.

  sudo mv /opt/local ~/macports
Error: 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.

    gdbm
    llvm
    nspr
    ossp-uuid
    pcre
    zsh
Error: Your compilers are different from the standard versions for your Xcode.
If you have Xcode 4.3 or newer, you should install the Command Line Tools for
Xcode from within Xcode's Download preferences.
Otherwise, you should reinstall Xcode.
Error: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:

    npm

Consider amending your PATH so that /usr/local/bin
is ahead of /usr/bin in your PATH.
Error: Your Xcode is configured with an invalid path.
You should change it to the correct path. Please note that there is no correct
path at this time if you have *only* installed the Command Line Tools for Xcode.
If your Xcode is pre-4.3 or you installed the whole of Xcode 4.3 then one of
these is (probably) what you want:

    sudo xcode-select -switch /Developer
    sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

DO NOT SET / OR EVERYTHING BREAKS!

Please help.
Thanks

wright commented Jun 13, 2012

I have a similar problem. Everything I have installed or updated in the last few days is not being linked, but if I run 'brew link whatever', that succeeds.

When I write "brew link foo", it says I can't symlink for some reason.

Contributor

adamv commented Jul 23, 2012

@jacknagel are these cases covered by a quick-fix?

Contributor

jacknagel commented Jul 23, 2012

Dunno; I couldn't reproduce any of this, though.

Contributor

2bits commented Jul 23, 2012

I have been getting this frequently the last few days. Some random dep will install but not link correctly. The last case was gtk. I had a previous version installed. I did a brew rm -f gtk and then a brew install gtk. It failed to link because it said a dylib from the previous version still existed. It did still exist which is wrong. It should have been completely removed with brew rm -f. Does that help at all?

Contributor

adamv commented Jul 23, 2012

I've also been getting seemingly random linking errors.

Contributor

jacknagel commented Jul 24, 2012

$ git log --oneline --since=2.months.ago -- Library/Homebrew/keg.rb
66a4ea1 Keg#unlink: check destination before unlinking
3870c93 Keg#unlink: Don't try to unlink if keg is unlinked
8b6e6af Fix brew link --dry-run
bf05105 link: add --force and --dry-run options
dd77bb8 Keg#unlink: skip find for non-extant files

If someone can reliably reproduce a failure here, it should be easy to bisect.

Contributor

adamv commented Jul 24, 2012

@mistydemeo mistydemeo added a commit that referenced this issue Jul 24, 2012

@mistydemeo mistydemeo Revert 66a4ea1
Refusing to unlink files from another keg introduced issues when
files changed between formula versions; for instance, this
introduced issues when upgrading from gtk+ 2.24.10 to 2.24.11.

See #12778.
02f66b5
Contributor

mistydemeo commented Jul 24, 2012

I introduced a bug in 66a4ea1; reverted all of the Keg#unlink changes. I'm sorry about that. However, that was only two days ago - it fixes @2bits's gtk problems, but not the older ones.

The only other Keg#unlink change I made was in dd77bb8, to skip a method call that's always a no-op on 1.8, and raises an exception on 1.9.

The only changes to #unlink were in the past few days, so it's possible the other problems come from somewhere other than Keg. However, I'll take a look at #link too.

Contributor

mistydemeo commented Jul 24, 2012

The first three posts come from 2012-06-12 and predate my changes to brew link and unlink; before that Keg and formula_installer hadn't been touched since April. Hm. Wish there was a reproduceable case.

Contributor

jacknagel commented Jul 25, 2012

What exactly was the bug you introduced? Maybe I'm not thinking straight because it is late, but isn't Keg#unlink basically:

  • Walk the keg using Pathname#find;
  • for each directory or file encountered, create a Pathname object that is a relative symlink from HOMEBREW_PREFIX back into the keg, and check if it exists;
  • If it does, remove it.

What I don't really understand is what you are alluding to in the commit message for 02f66b5. Shouldn't Keg#unlink be oblivious to that? i.e., shouldn't it be smart enough to unlink exactly the set of files that have relative symlinks back into the keg?

Please correct what I am misunderstanding here.

Contributor

mistydemeo commented Jul 25, 2012

No, I agree with you - that's what it should have been doing. I suspect some other funny business is going on here, and I inadvertantly exposed another bug somewhere else.

With gtk+ for example, when upgrading this commit introduced a situation where not all gtk+ files were being unlinked by brew upgrade or before installing. That led to the upgrade failures some users were seeing.

brew ln gtk+
Linking /usr/local/Cellar/gtk+/2.24.10... 245 symlinks created
brew unlink gtk+
Unlinking /usr/local/Cellar/gtk+/2.24.10... 242 links removed
Contributor

mistydemeo commented Jul 25, 2012

Derp. The three files not being unlinked properly are symlinks themselves in the Cellar, and I wasn't properly following the symlinks on both src and dst - so naturally the comparison was failing.

Contributor

jacknagel commented Jul 25, 2012

Ahhh.

Contributor

mistydemeo commented Jul 25, 2012

(That said, it looks like brew ln and brew unlink have different counting criteria. Even though the same list of files is being linked/unlinked, they still don't line up.)

Contributor

jacknagel commented Jul 25, 2012

Whatever the resolution ends up being, we need to better document this method, so that we aren't scratching our heads again in six months.

@Sharpie Sharpie pushed a commit to Sharpie/homebrew that referenced this issue Jul 25, 2012

@mistydemeo mistydemeo Revert 66a4ea1
Refusing to unlink files from another keg introduced issues when
files changed between formula versions; for instance, this
introduced issues when upgrading from gtk+ 2.24.10 to 2.24.11.

See #12778.
d4b806d
Contributor

mistydemeo commented Jul 25, 2012

Yeah, for sure. I'll try to comment a few of the more magickal bits of link and unlink when I fix this.

Contributor

adamv commented Aug 10, 2012

Any word here?

Contributor

mistydemeo commented Aug 10, 2012

Sorry. I was working on that right before I left on vacation and my laptop died. Will get this done soonish.

@fgeller fgeller added a commit to fgeller/homebrew that referenced this issue Aug 22, 2012

@mistydemeo @fgeller mistydemeo + fgeller Revert 66a4ea1
Refusing to unlink files from another keg introduced issues when
files changed between formula versions; for instance, this
introduced issues when upgrading from gtk+ 2.24.10 to 2.24.11.

See #12778.
9cd63e1
Contributor

adamv commented Oct 3, 2012

Ping.

Contributor

mistydemeo commented Oct 5, 2012

Addressed (finally) in b11de18. I also pushed another couple of improvements to the link/unlink code (and some comments).

mistydemeo closed this Oct 5, 2012

Contributor

jacknagel commented Oct 5, 2012

Hooray!

Member

mxcl commented Oct 5, 2012

@mistydemeo you deserve much praise.

@snakeyroc3 snakeyroc3 pushed a commit to snakeyroc3/homebrew that referenced this issue Dec 17, 2012

@mistydemeo mistydemeo Revert 66a4ea1
Refusing to unlink files from another keg introduced issues when
files changed between formula versions; for instance, this
introduced issues when upgrading from gtk+ 2.24.10 to 2.24.11.

See #12778.
80f9a64

xu-cheng locked and limited conversation to collaborators Feb 16, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.