brew update and retried your prior step?brew doctor, fixed as many issues as possible and retried your prior step?After upgrading Ruby to latest 2.4.1_1 formula, gem command no longer works and gives the following error:
/usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/yaml.rb:5:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
/usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/usr/local/lib/ruby/gems/2.4.0/gems/psych-2.2.4/lib/psych.bundle, 9): Library not loaded: /usr/local/opt/ruby/lib/libruby.2.4.0.dylib (LoadError)
Referenced from: /usr/local/lib/ruby/gems/2.4.0/gems/psych-2.2.4/lib/psych.bundle
Reason: image not found - /usr/local/lib/ruby/gems/2.4.0/gems/psych-2.2.4/lib/psych.bundle
from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/lib/ruby/gems/2.4.0/gems/psych-2.2.4/lib/psych.rb:8:in `<top (required)>'
from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/yaml.rb:6:in `<top (required)>'
from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems.rb:700:in `load_yaml'
from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/config_file.rb:340:in `load_file'
from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/config_file.rb:202:in `initialize'
from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:75:in `new'
from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:75:in `do_configuration'
from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:40:in `run'
from /usr/local/bin/gem:21:in `<main>'
I tried both
brew reinstall -s libyaml
and
brew reinstall -s ruby
but none of them resolved the issue.
Could anyone help me fix this?
Many thanks.
maybe
rm -rf /usr/local/lib/ruby/site_ruby/
brew uninstall ruby
brew install ruby
gem install psych
@ilovezfs Thanks for the suggestion, but it still didn't resolve the issue, throwing the same error.
what command are you running
I followed your steps for removing and installing Ruby, and I tried any gem command – just gem, gem update, gem update --system, gem install psych, and so on, but none of them works.
looks fine here starting from clean install: https://gist.github.com/ilovezfs/48a77d39c08220f34d9e8ead7d51656b
so not sure what to tell you
Strange. I tried with [email protected], and it is working without any problem. But as soon as I upgrade it to 2.4.1, the problem pops up again.
what's output for brew config and brew doctor
dorapen@~$ brew config
HOMEBREW_VERSION: 1.1.11
ORIGIN: https://github.com/Homebrew/brew
HEAD: 394f9fa0aaa5854aa52bc589708a079665dcf462
Last commit: 3 weeks ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: e360ded5f8533c30e58a095b2263965af8d50988
Core tap last commit: 17 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local/Homebrew
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: octa-core 64-bit haswell
Homebrew Ruby: 2.0.0-p648
Clang: 8.0 build 800
Git: 2.12.2 => /usr/local/bin/git
Perl: /usr/local/bin/perl => /usr/local/Cellar/perl/5.24.1/bin/perl
Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /usr/local/bin/ruby => /usr/local/Cellar/ruby/2.4.1_1/bin/ruby
Java: 1.8.0_121, 1.8.0_112, 1.7.0_80
macOS: 10.12.3-x86_64
Xcode: 8.2.1
CLT: 8.2.0.0.1.1480973914
X11: 2.7.11 => /opt/X11
dorapen@~$ brew doctor
Your system is ready to brew.
Im having the exact same problem.
All i did was brew update && brew upgrade and now gem is not working anymore.
I tried to reinstall both libyaml and ruby, but the error stays the same.
I checked if psych is there on my system. Everything seems to be there.
But /usr/local/opt/ruby/lib/libruby.2.4.0.dylib from the error message is not there.
How can i get this dylib?
@xu-cheng Any ideas here? I notice you may have done some related work on this in adfcc5a078c962ad1c687396da9096b2d4df916e.
Please try rm -rf /usr/local/lib/ruby/gems/2.4.0/gems/psych-2.2.4.
It is most likely a different version of psych is installed by users. However, that version is incorrectly linked to wrong lib file, which should be caused by the incorrect abi_version in https://github.com/Homebrew/homebrew-core/pull/11474
@dorapen @Bufallo please give that a try.
@ilovezfs @xu-cheng Nope, it didn't resolve the issue. I tried to reinstall ruby after deleting psych, both with brew reinstall ruby and brew reinstall -s ruby but neither worked. Also reinstalling libyaml didn't work.
This time following psych was referenced:
Referenced from: /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0/psych-2.2.4/psych.bundle
@dorpen What is the error message? Is it a different gem reporting the error?
A dramatical solution would be:
rm -rf /usr/local/lib/ruby
brew reinstall ruby
However, this would remove all installed rubygems.
@dorapen Oh, you could remove that file as well.
@xu-cheng Here's the error message:
dorapen@~$ gem
/usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/yaml.rb:5:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
/usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0/psych-2.2.4/psych.bundle, 9): Library not loaded: /usr/local/opt/ruby/lib/libruby.2.4.0.dylib (LoadError)
Referenced from: /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0/psych-2.2.4/psych.bundle
Reason: image not found - /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0/psych-2.2.4/psych.bundle
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/psych.rb:8:in `<top (required)>'
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/yaml.rb:6:in `<top (required)>'
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems.rb:700:in `load_yaml'
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/config_file.rb:340:in `load_file'
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/config_file.rb:202:in `initialize'
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/gem_runner.rb:75:in `new'
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/gem_runner.rb:75:in `do_configuration'
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/gem_runner.rb:40:in `run'
from /usr/local/bin/gem:21:in `<main>'
Oh hey! That solved it! So both:
rm -rf /usr/local/lib/ruby/gems/2.4.0/gems/psych-2.2.4
and
rm -rf /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0/psych-2.2.4
seems to do the trick! Thanks!!
@Bufallo does that take care of it for you too?
Yes!
After removing the psych gem wir rm -rf the gem command is working again.
Perfect. Thanks for the speedy help here @xu-cheng. It's much appreciated.
Many thanks to you both for the support, @ilovezfs and @xu-cheng!
Thank you so much for the solution. :)
Worked for me too!
rm -rf /usr/local/lib/ruby/gems/
brew uninstall ruby --ignore-dependencies
brew install ruby
Thanks so much for this!!!
@dorapen's solution above worked, thank you so much!
I've been dealing with the same error and @dorapen's solution worked for me:
rm -rf /usr/local/lib/ruby/gems/2.4.0/gems/psych-2.2.4
rm -rf /usr/local/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0/psych-2.2.4
Thank you!!!
Most helpful comment
Oh hey! That solved it! So both:
and
seems to do the trick! Thanks!!