Brew update error dependent dylib '/usr/local/opt/libyaml/lib/libyaml-0.2.dylib' not found

I can regularly can do brew update with no issue, but this morning I had this popping up. I tried to google some threads and solution but nothing seems to work on my computer. Can anyone point me to the right direction to solve this?

brew update                                                                                                                                             ─╯
Traceback (most recent call last):
	18: from /usr/local/Homebrew/Library/Homebrew/brew.rb:31:in `<main>'
	17: from /usr/local/Homebrew/Library/Homebrew/brew.rb:31:in `require_relative'
	16: from /usr/local/Homebrew/Library/Homebrew/global.rb:26:in `<top (required)>'
	15: from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/i18n-1.8.5/lib/i18n.rb:55:in `backend'
	14: from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/i18n-1.8.5/lib/i18n/config.rb:21:in `backend'
	13: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	12: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	11: from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/i18n-1.8.5/lib/i18n/backend/simple.rb:3:in `<top (required)>'
	10: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 9: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 8: from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/i18n-1.8.5/lib/i18n/backend/base.rb:3:in `<top (required)>'
	 7: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 6: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 5: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/yaml.rb:4:in `<top (required)>'
	 4: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 3: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 2: from /Library/Ruby/Gems/2.6.0/gems/psych-3.2.0/lib/psych.rb:13:in `<top (required)>'
	 1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': dlopen(/Library/Ruby/Gems/2.6.0/gems/psych-3.2.0/lib/psych.bundle, 0x0009): dependent dylib '/usr/local/opt/libyaml/lib/libyaml-0.2.dylib' not found for '/Library/Ruby/Gems/2.6.0/gems/psych-3.2.0/lib/psych.bundle' - /Library/Ruby/Gems/2.6.0/gems/psych-3.2.0/lib/psych.bundle (LoadError)

Brew install libyaml would work. Or gem uninstall psych --all

I got this exact same error doing both commands above. It’s quite weird because there was nothing wrong yesterday when I executed brew upgrade.

 brew install libyaml                                                                                            ─╯
Updating Homebrew...
Traceback (most recent call last):
	18: from /usr/local/Homebrew/Library/Homebrew/brew.rb:31:in `<main>'
	17: from /usr/local/Homebrew/Library/Homebrew/brew.rb:31:in `require_relative'
	16: from /usr/local/Homebrew/Library/Homebrew/global.rb:26:in `<top (required)>'
	15: from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/i18n-1.8.5/lib/i18n.rb:55:in `backend'
	14: from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/i18n-1.8.5/lib/i18n/config.rb:21:in `backend'
	13: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	12: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	11: from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/i18n-1.8.5/lib/i18n/backend/simple.rb:3:in `<top (required)>'
	10: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 9: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 8: from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/i18n-1.8.5/lib/i18n/backend/base.rb:3:in `<top (required)>'
	 7: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 6: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 5: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/yaml.rb:4:in `<top (required)>'
	 4: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 3: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 2: from /Library/Ruby/Gems/2.6.0/gems/psych-3.2.0/lib/psych.rb:13:in `<top (required)>'
	 1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': dlopen(/Library/Ruby/Gems/2.6.0/gems/psych-3.2.0/lib/psych.bundle, 0x0009): dependent dylib '/usr/local/opt/libyaml/lib/libyaml-0.2.dylib' not found for '/Library/Ruby/Gems/2.6.0/gems/psych-3.2.0/lib/psych.bundle' - /Library/Ruby/Gems/2.6.0/gems/psych-3.2.0/lib/psych.bundle (LoadError)

In fact, in my case, simply executing gem also invoked the error.

What happens if you run HOMEBREW_FORCE_VENDOR_RUBY=1 brew upgrade

This fixed my issue. Do you know what the root cause is?

You broke your ruby install somehow, so this makes brew use it’s own version of ruby.

1 Like