Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homebrew Cannot Update, Doctor, Unlink, etc. #991

Closed
stonemirror opened this issue Sep 17, 2016 · 22 comments
Closed

Homebrew Cannot Update, Doctor, Unlink, etc. #991

stonemirror opened this issue Sep 17, 2016 · 22 comments
Labels
bug Reproducible Homebrew/brew bug

Comments

@stonemirror
Copy link

stonemirror commented Sep 17, 2016

Bug reports:

I ran a brew update yesterday unproblematically. Today, no matter what I try to do, I'm getting the following response:

Error: Could not symlink bin/easy_install
Target /usr/local/bin/easy_install
is a symlink belonging to python. You can unlink it:
  brew unlink python

To force the link and overwrite all conflicting files:
  brew link --overwrite python3

To list all files that would be deleted:
  brew link --overwrite --dry-run python3

Executing any of the brew link or brew unlink commands results in the same error. Removing the symlink and rerunning the command gives the same error; the symlink file reappears after any such attempt. I get the same error in response to a brew doctor command. I'm kind of at a loss here.

I also attempted the following:

chown -R $USER:admin /usr/local
cd /usr/local
git reset --hard origin/master
brew update

which, again, resulted in the same error.

I've made no changes since yesterday except that I upgraded my copy of Xcode (and the Xcode command line tools), so I'm guessing that's what might be responsible somehow. Any suggestions as to how I might produce better information on what's going on here would be welcome...

@zmwangx
Copy link
Contributor

zmwangx commented Sep 17, 2016

Latest update. If you update to the latest version of brew it should probably heal itself now. Make sure you run brew update TWICE.


Caution: This workaround may not be up-to-date!


Before anything else, to update brew to the latest (assuming brew is installed to /usr/local):

cd /usr/local; git fetch; git reset --hard origin/master

Please AN OLD COMMAND THAT'S NO LONGER NEEDED and that should probably get you back on your feet again. Sorry.

Note: Please run the above command with caution. It's probably best to take a look at what's inside /usr/local/Library/LinkedKegs first and make sure they're nothing but a bunch of symlinks.


There's a brief explanation of what happened below.

@stonemirror
Copy link
Author

stonemirror commented Sep 17, 2016

Thanks, but I'm receiving the same error:

<<mcfate::local>> $ AN OLD COMMAND THAT'S NO LONGER NEEDED
<<mcfate::local>> $ brew update
Error: Could not symlink bin/easy_install
Target /usr/local/bin/easy_install
is a symlink belonging to python. You can unlink it:
  brew unlink python

To force the link and overwrite all conflicting files:
  brew link --overwrite python3

To list all files that would be deleted:
  brew link --overwrite --dry-run python3
<<mcfate::local>> $

@zmwangx
Copy link
Contributor

zmwangx commented Sep 17, 2016

Please attach --debug to brew update.

@enriquefernandez
Copy link

enriquefernandez commented Sep 17, 2016

I was having a similar issue and just run AN OLD COMMAND THAT'S NO LONGER NEEDED

What is that supposed to do?
Do I need to "refix" that somehow?

I don't think I've updated Xcode, so I don't really know why this happened...

@stonemirror
Copy link
Author

I've posted a gist of the debug output here...

@zmwangx
Copy link
Contributor

zmwangx commented Sep 17, 2016

@enriquefernandez

First, did that fix the problem for you?


We're migrating /usr/local/Library/LinkedKegs to /usr/local/var/homebrew/linked (and /usr/local/Library/PinnedKegs to /usr/local/var/homebrew/pinned for that matter) and unfortunately there were bugs in migration code that had done damage that may be hard to remedy within brew without a lot of complication.

AN OLD COMMAND THAT'S NO LONGER NEEDED

What is that supposed to do?

Blow away the old directory that somehow failed to migrate.

Do I need to "refix" that somehow?

You may need to brew unlink $(brew ls); brew link $(brew ls) to restore keg links into /usr/local/var/homebrew/linked (ignore the keg-only warnings).

@zmwangx
Copy link
Contributor

zmwangx commented Sep 17, 2016

@stonemirror Could you try cd /usr/local; git fetch; git reset --hard origin/master?

@publicarray
Copy link

@zmwangx thanks that worked. It did fail on rake and python for some reason. I fixed it by reinstalling them.

@stonemirror
Copy link
Author

Okay, I seem to be getting closer to something that's working; I got an Already up-to-date response from brew update and I'm running a brew upgrade now, which seems to be working. I think I may have to uninstall and reinstall python3, but that's do-able.

@zmwangx
Copy link
Contributor

zmwangx commented Sep 17, 2016

@publicarray Those appear to be conflicting files from multiple formulae. For instance, in OP's case, python3 is trying to link its bin/easy_install while it should only have bin/easy_install-3.5, so I'm not exactly sure what's going on. Maybe not the latest version; or maybe it was built with some not heavily-tested options.

@enriquefernandez
Copy link

enriquefernandez commented Sep 17, 2016

It partially solved my issues. Brew commands now work and I can update and install new things.

When running brew unlink $(brew ls); brew link $(brew ls) I'm getting errors about homebrew not being able to create symlinks.

Example:

Error: Could not symlink lib/pkgconfig/eigen3.pc
Target /usr/local/lib/pkgconfig/eigen3.pc
already exists. You may want to remove it:
  rm '/usr/local/lib/pkgconfig/eigen3.pc'

To force the link and overwrite all conflicting files:
  brew link --overwrite eigen

To list all files that would be deleted:
  brew link --overwrite --dry-run eigen

After running brew link --overwrite --dry-run eigen now I'm getting the same with gfortran:

Error: Could not symlink bin/gfortran
Target /usr/local/bin/gfortran
is a symlink belonging to gcc. You can unlink it:
  brew unlink gcc

To force the link and overwrite all conflicting files:
  brew link --overwrite gfortran

To list all files that would be deleted:
  brew link --overwrite --dry-run gfortran

Got one more error with ghostcript that was solved in the same way: brew link --overwrite ghostscript

After that, brew link $(brew ls) completed successfully, and it seems like everything is working normally now.

Thanks!

@zmwangx
Copy link
Contributor

zmwangx commented Sep 17, 2016

@stonemirror Good to hear, let us know if you're hitting other errors (other than conflicting links, which usually means you either have stale links that you could safely remove, or for some reason you have conflicting files from multiple formulae, which you should try to resolve by reinstalling the formula at question first).

@zmwangx
Copy link
Contributor

zmwangx commented Sep 17, 2016

@enriquefernandez Yeah unfortunately you have to resolve them one at a time, each time followed by a rerun of brew link $(brew ls).

brew list | xargs -n1 brew link might help ease the process (you only need to run that once), but you'll need to pick out the errors from a stream of output and resolve them.

@enriquefernandez
Copy link

Solved! (sorry, updated my previous comment before seeing your reply)

@zmwangx
Copy link
Contributor

zmwangx commented Sep 17, 2016

@enriquefernandez As for gfortran in particular, it's a stale formula you have and you should probably just brew uninstall --force gfortran. It's now provided as part of gcc.

@zmwangx
Copy link
Contributor

zmwangx commented Sep 17, 2016

@enriquefernandez Glad to hear.

@stonemirror
Copy link
Author

Yeah, I've uninstalled and reinstalled python3 after my science/opencv upgrade failed, and rerun the brew upgrade --all. Seems to be working again, or at least the problems at this point seem to be OpenCV's, not Homebrew's... 😆

I'll close this, thanks for the help, @zmwangx!

@zmwangx
Copy link
Contributor

zmwangx commented Sep 17, 2016

Let's leave this open for a while actually for visibility.

@zmwangx zmwangx reopened this Sep 17, 2016
@zmwangx zmwangx added the bug Reproducible Homebrew/brew bug label Sep 17, 2016
@MikeMcQuaid
Copy link
Member

#992 or similar will hopefully address this case a bit better.

@zmwangx zmwangx changed the title Homebrew Cannot Update, Doctor, Unlink, etc. since Xcode update? Homebrew Cannot Update, Doctor, Unlink, etc. Sep 17, 2016
@zmwangx
Copy link
Contributor

zmwangx commented Sep 17, 2016

Edited title to uncouple from Xcode update.

@ashfurrow
Copy link
Contributor

Running brew update twice fixed it for me (was seeing this on CI), thanks @zmwangx for adding that solution to the top of the discussion 👍

@zmwangx
Copy link
Contributor

zmwangx commented Sep 19, 2016

Affected folks have probably sought (and hopefully found) help already. Closing.

@zmwangx zmwangx closed this as completed Sep 19, 2016
@ghost ghost assigned zmwangx Sep 19, 2016
@Homebrew Homebrew locked and limited conversation to collaborators May 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Reproducible Homebrew/brew bug
Projects
None yet
Development

No branches or pull requests

6 participants