Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

Rubyの環境には2種類の状態しかない。

More than 3 years have passed since last update.

壊れているか、これから壊れるかだ。

というわけでいつの間にか、gemを実行すると以下のエラーが出るようになってしまった。

hichon-no-MacBook-Pro:~ hichon$ gem list
/usr/local/Cellar/ruby/2.4.3_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.1.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.3_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:701: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>'

復旧方法

問題のファイルを手動で削除して、該当のパッケージを再インストールして復旧した。

$ rm /usr/local/lib/ruby/gems/2.4.0/gems/psych-2.2.4/lib/psych.bundle
$ gem uninstall psych
$ gem install psych
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away