Question

Short version: I think I've made a huge mess of my brew installation, and I'm not sure what to do.

Long version...

I started out the day trying to install ruby:

brew install ruby

which seemed pretty simple. Immediately I ran into this error:

Error: Cannot write to /usr/local/Cellar

After running brew doctor I discovered a long list of errors of the form

Warning: /usr/local/<dir> isn't writable.
This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a brew tries to write a file to this directory, the
install will fail during the link step.

Eventually I solved this with a gigantic chmod, namely

sudo chmod -R 777 /usr/local

which seemed to do the trick.

From there I tried a simple "brew update". This gave me a new issue:

error: Your local changes to the following files would be overwritten by merge:
<list of about 100 files>
Please, commit your changes or stash them before you can merge.

Unsure what else to do, I ran "git commit" and successfully committed my changes (I have no idea what they were). I figured it would be easy just to overwrite the changes when merging with brew update...

...and that was definitely not the case. Here's some sample output from brew update:

Auto-merging share/man/man1/brew.1
Auto-merging Library/Homebrew/version.rb
CONFLICT (content): Merge conflict in Library/Homebrew/version.rb
Auto-merging Library/Homebrew/test/testing_env.rb
Auto-merging Library/Homebrew/test/test_versions.rb
CONFLICT (content): Merge conflict in Library/Homebrew/test/test_versions.rb
Auto-merging Library/Homebrew/test/test_requirement.rb
Auto-merging Library/Homebrew/test/test_formula_validation.rb
CONFLICT (modify/delete): Library/Homebrew/test/test_dependency_expansion.rb deleted in HEAD and modified in 9e3aa8925cf4b03a5b1fda13971dde84e1162c41.

Now all of my files in brew have "<<<<<<< HEAD"'s and ">>>>>>> [hashcode]"'s strewn about in them. To try to fix this, I ran a few commands I found here:

git checkout --theirs *
git add .
git merge

I don't have much git experience, but I'm now fairly sure this was a terrible idea. Git is convinced I have no changes to merge, but all of the "<<<<<<< HEAD" etc. tags are still in my code. I can't even run "brew doctor" or "brew update" because the base code of brew is not readable.

CONCLUSION...

I feel like the best idea would be to uninstall and reinstall brew, except that I would then have to reinstall all my brew installations. And because I can't run "brew list", I have no idea what these are. Is there still a way I can accept all of the remote changes? What can I do now?

Était-ce utile?

La solution

chmod -R 777 is extremely bad for security. This makes every file and directory under it world readable writable and executable meaning everybody can do what they like with it.

At the very most directories should have permissions of 775 - better 755 and files should either be 664 or 644 unless they are executable files as exists in /usr/local/bin in which case they should be 755 again.

The recursive change to /usr/local/ means that every file listed in the status / commit had permission changes to it which is why brew has complained. Might not look like much but it means the world to git and the security of your system.

The only way to get this back is to reset the permissions on each file / directory under /usr/local/ and then remove your commit entirely with git reset --hard origin/master

brew doesn't play nicely with other applications at all and where possible I'd recommend avoiding its use unless you really need to.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top