ruby-on-rails - rails 5, rbenv - rails 控制台未启动 - 库未加载 :/usr/local/opt/readline/lib/libreadline. 7.dylib (LoadError)

标签 ruby-on-rails console rbenv

当我在终端中运行“rails c”命令时,不知何故它不会启动 rails 控制台并抛出错误。我正在使用 rbenv 运行 rails 5.2.2。

rails c

它引发以下错误。
Running via Spring preloader in process 13912
Traceback (most recent call last):
    50: from -e:1:in `<main>'
    49: from /Users/wemteq/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
    48: from /Users/wemteq/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
    47: from /Users/wemteq/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:285:in `load'
    ...
     7: from /Users/wemteq/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
     6: from /Users/wemteq/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
     5: from /Users/wemteq/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
     4: from /Users/wemteq/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
     3: from /Users/wemteq/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
     2: from /Users/wemteq/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
     1: from /Users/wemteq/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/Users/wemteq/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require': dlopen(/Users/wemteq/.rbenv/versions/2.5.0/lib/ruby/2.5.0/x86_64-darwin17/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib (LoadError)
  Referenced from: /Users/wemteq/.rbenv/versions/2.5.0/lib/ruby/2.5.0/x86_64-darwin17/readline.bundle
  Reason: image not found - /Users/wemteq/.rbenv/versions/2.5.0/lib/ruby/2.5.0/x86_64-darwin17/readline.bundle

它在一周前有效,但现在无效。有任何想法吗?

最佳答案

我从一些研究中找到了 2 个解决方案。

Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib (LoadError)
  • libreadline.7.dylib 丢失,因此将 libreadline.8.0.dylib 链接到 libreadline.7.dylib 对我有用。

    ln -s/usr/local/opt/readline/lib/libreadline.8.0.dylib/usr/local/opt/readline/lib/libreadline.7.dylib

  • libreadline version might be different. You can browse available files in /usr/local/opt/readline/lib/ directory.


  • rb-readline gem 在开发组可以解决这个问题。

    gem 'rb-readline'
  • 关于ruby-on-rails - rails 5, rbenv - rails 控制台未启动 - 库未加载 :/usr/local/opt/readline/lib/libreadline. 7.dylib (LoadError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54660451/

    相关文章:

    仅包含在单页 Rails 中的 CSS 文件不适用于服务器

    ruby-on-rails - 如何使用 Heroku 和 Cloudfront 为 Rails 激活页面缓存?

    ruby-on-rails - bundler + 防护 + Rspec + Rbenv = "You have already activated..."

    ruby - 很难在 Mac 上安装 Ruby

    rvm - zsh中rbenv版本显示右键提示不刷新

    ruby-on-rails - Rspec 请求规范检查响应正文

    ruby-on-rails - 找不到 libcurl 或 curl/curl.h (RuntimeError)

    c++ - 在 Windows 控制台中显示 unicode 棋子

    javascript - 在控制台中使用 JavaScript 获取用户输入

    linux - 是否可以将文件重定向到控制台程序,就像用户键入内容一样?