Ruby无法加载此类文件-active_support / core_ext / object / blank

时间:2019-02-26 15:10:38

标签: ruby rubygems homebrew

我试图运行brew doctor,但系统弹出错误消息

  

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in   `require':无法加载此类文件-   active_support / core_ext / object / blank(LoadError)

在网上搜索过,另一则帖子建议只是“ gem install activesupport”,但随后我遇到了以下错误:

ERROR:  Error installing activesupport:
    i18n requires Ruby version >= 2.3.0.

我还尝试了rvm安装ruby-2.3.0,但再次弹出相同的错误

[2019-02-26 10:07:41] requirements_osx_brew_libs_install
requirements_osx_brew_libs_install ()  { 
    brew install "$@" --force || { 
        \typeset ret=$?;
        requirements_osx_brew_libs_error "installation";
        return $ret
    } } current path: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib
PATH=/Users/{user_name}/.aw/pex_resources/scripts/binaries:/usr/local/sbin:/Users/fengjiao/.rbenv/shims:/Users/{user_name}/.nvm/v0.10.32/bin:/Users/fengjiao/bin:/usr/local/sbin:/usr/local/bin:/Users/{user_name}/.rbenv/shims:/Users/{user_name}/.nvm/v0.10.32/bin:/Users/{user_name}/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/munki:/opt/X11/bin:/Users/fengjiao/gocode/bin:/Users/{user_name}/.rvm/bin
command(10): requirements_osx_brew_libs_install autoconf automake
libtool pkg-config coreutils libyaml readline libksba openssl@1.1
++ brew install autoconf automake libtool pkg-config coreutils libyaml readline libksba openssl@1.1 --force
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in
`require': cannot load such file --
active_support/core_ext/object/blank (LoadError)    from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in
`require'   from /usr/local/Homebrew/Library/Homebrew/global.rb:10:in
`<top (required)>'  from
/usr/local/Homebrew/Library/Homebrew/brew.rb:21:in `require_relative'
    from /usr/local/Homebrew/Library/Homebrew/brew.rb:21:in `<main>'
++ typeset ret=1
++ requirements_osx_brew_libs_error installation
++ rvm_warn 'There were package installation errors, make sure to read the log.

Try `brew tap --repair` and make sure `brew doctor` looks reasonable.

4 个答案:

答案 0 :(得分:69)

运行brew style为我解决了此问题。


更新

如评论中所述,对于某些人来说,解决方案是:

brew update-reset

答案 1 :(得分:7)

有同样的问题。我必须运行brew update-reset进行修复。

答案 2 :(得分:1)

我在将 ruby​​ 版本 ruby​​ 2.2 升级到 ruby​​ 2.5 for rails 4.2 时遇到了“sunspot_rails-2.1.0”问题,在这里我想与您分享对我有用的方法。

“加载错误:没有要加载的文件 -- active_support/core_ext/object/to_json

参考https://github.com/sunspot/sunspot/pull/555/files

答案 3 :(得分:0)

就我而言,我必须强制homebrew / linuxbrew使用其自己的Portable-ruby对其进行修复。

我正在运行安装了ruby 2.7.0的ArchLinux,按照manpage并发布export HOMEBREW_FORCE_VENDOR_RUBY=1所述,由brew update切换到homebrew的Portable-ruby之后,homebrew自动下载了便携式-红宝石2.6.3,一切恢复正常。

我认为根本原因可能是自制软件与更高版本的红宝石不兼容。