Please follow the general troubleshooting steps first:
You can erase any parts of this template not applicable to your Issue.
Bug reports:
Somehow, I had a symlink in /usr/local/opt, specifically gnu-which, that was created with a null destination.
$ ls -d /usr/local/opt/gnu-which
lrwxr-xr-x 1 kirb staff 24 Apr 14 21:39 gnu-which ->
This broke almost all brew commands, which would throw this:
Error: pathname contains null byte
Please report this bug:
https://git.io/brew-troubleshooting
/usr/local/Library/Homebrew/extend/pathname.rb:340:in `initialize'
/usr/local/Library/Homebrew/extend/pathname.rb:340:in `readlink'
/usr/local/Library/Homebrew/extend/pathname.rb:340:in `resolved_path'
/usr/local/Library/Homebrew/keg.rb:189:in `optlinked?'
/usr/local/Library/Homebrew/formulary.rb:215:in `each'
/usr/local/Library/Homebrew/formulary.rb:215:in `detect'
/usr/local/Library/Homebrew/formulary.rb:215:in `from_rack'
/usr/local/Library/Homebrew/diagnostic.rb:1339:in `block in check_for_unlinked_but_not_keg_only'
/usr/local/Library/Homebrew/diagnostic.rb:1336:in `reject'
/usr/local/Library/Homebrew/diagnostic.rb:1336:in `check_for_unlinked_but_not_keg_only'
/usr/local/Library/Homebrew/cmd/doctor.rb:38:in `block in doctor'
/usr/local/Library/Homebrew/cmd/doctor.rb:31:in `each'
/usr/local/Library/Homebrew/cmd/doctor.rb:31:in `doctor'
/usr/local/Library/brew.rb:97:in `<main>'
Obviously this isn’t very helpful to finding the culprit, and I only found the culprit by luck. I don’t know how the bad symlink was created in the first place – after deleting it, I inspected its directory in the cellar and nothing seems out of place. Linking it manually also worked.
Feature Requests:
I would figure there should be a check to confirm the destination is not empty when creating symlinks. Possibly also add a check for this to brew doctor? It was the first thing I tried, hoping it would fix it.
Please follow the general troubleshooting steps first:
brew updateand retried your prior step?brew doctor, fixed as many issues as possible and retried your prior step?sudo chown -R $(whoami) $(brew --prefix)?You can erase any parts of this template not applicable to your Issue.
Bug reports:
Somehow, I had a symlink in /usr/local/opt, specifically
gnu-which, that was created with a null destination.This broke almost all brew commands, which would throw this:
Obviously this isn’t very helpful to finding the culprit, and I only found the culprit by luck. I don’t know how the bad symlink was created in the first place – after deleting it, I inspected its directory in the cellar and nothing seems out of place. Linking it manually also worked.
Feature Requests:
I would figure there should be a check to confirm the destination is not empty when creating symlinks. Possibly also add a check for this to
brew doctor? It was the first thing I tried, hoping it would fix it.