-1

I recently upgraded to macOS Mojave 10.14.1 and when using the native Terminal or iTerm, the vim command appeared to be broken. The error will look like

dudeOnMac:~ freddy$ vim file
dyld: Library not loaded: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/libruby.2.0.0.dylib
  Referenced from: /usr/local/bin/vim
  Reason: image not found

I found this SuperUser post which wasn't quite solving the problem. Other few suggestions were to re-install Vim from scratch from base. So I did a

brew update
brew upgrade vim

but left with the following error

==> Upgrading vim 
Error: The following formula
  [#<Dependency: "python" []>, #<Options: []>]
cannot be installed as binary package and must be built from source.
Install the Command Line Tools:
  xcode-select --install

So I went in and did installation of xcode as suggested above, but left with a new error now as

Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
pathname contains null byte
Error: pathname contains null byte
Please report this bug:
  https://docs.brew.sh/Troubleshooting
/usr/local/Homebrew/Library/Homebrew/extend/pathname.rb:265:in `initialize'
/usr/local/Homebrew/Library/Homebrew/extend/pathname.rb:265:in `readlink'
/usr/local/Homebrew/Library/Homebrew/extend/pathname.rb:265:in `resolved_path'
/usr/local/Homebrew/Library/Homebrew/keg.rb:422:in `block in oldname_opt_record'
/usr/local/Homebrew/Library/Homebrew/keg.rb:421:in `each'
/usr/local/Homebrew/Library/Homebrew/keg.rb:421:in `find'
/usr/local/Homebrew/Library/Homebrew/keg.rb:421:in `oldname_opt_record'
/usr/local/Homebrew/Library/Homebrew/keg.rb:535:in `optlink'
/usr/local/Homebrew/Library/Homebrew/keg.rb:432:in `link'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:801:in `link'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:619:in `finish'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:586:in `install_dependency'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:539:in `block in install_dependencies'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:539:in `each'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:539:in `install_dependencies'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:252:in `install'
/usr/local/Homebrew/Library/Homebrew/cmd/upgrade.rb:187:in `upgrade_formula'
/usr/local/Homebrew/Library/Homebrew/cmd/upgrade.rb:136:in `block in upgrade_formulae'
/usr/local/Homebrew/Library/Homebrew/cmd/upgrade.rb:133:in `each'
/usr/local/Homebrew/Library/Homebrew/cmd/upgrade.rb:133:in `upgrade_formulae'
/usr/local/Homebrew/Library/Homebrew/cmd/upgrade.rb:111:in `upgrade'
/usr/local/Homebrew/Library/Homebrew/brew.rb:102:in `<main>'
Blazej SLEBODA
  • 8,936
  • 7
  • 53
  • 93
Inian
  • 80,270
  • 14
  • 142
  • 161

1 Answers1

0

I tried to closely follow the steps from the homebrew maintainers page - Error: pathname contains null byte and Broken symlink detection needed which wasn't explaining the exact problem.

I went in and ran brew doctor and tried to fix one issue by one. First was to create the directory /usr/local/sbin which wasn't present and add the right permission

sudo mkdir -p /usr/local/sbin
sudo chown -R $(whoami) /usr/local/sbin

Even after this running brew upgrade vim was showing the same error

Error: pathname contains null byte

One of the pages in the initial link suggested some broken symlink could have caused the issue, I went in and looked under /usr/local/opt which had the utils linked to the path from Cellar, but readline was broken without pointing to anywhere

lrwxr-xr-x  1 freddy  admin    26B Apr 18  2017 readline -> 

which seemed to the culprit, removed it using

rm -rf /usr/local/opt/readline

and did a fresh brew upgrade vim which now installed the required dependencies and successfully installed vim. I had the same problem for awk which I had to fix using brew upgrade gawk.

Inian
  • 80,270
  • 14
  • 142
  • 161