我无法访问Rails控制台

时间:2019-03-07 14:44:50

标签: ruby-on-rails ruby macos ruby-on-rails-4 rubygems

我无法访问rails控制台,正在使用MAC Mojave。 我尝试使用以下替代方法解决问题,但仍然出现相同的错误。

https://gist.github.com/wbotelhos/46c37807c834ccb5bb406e426adfe347

如果我打开一个新终端并编写ruby -v,则ruby出现2.3.7 但是前一段时间,我删除了这个版本的ruby。

但是我无法确定删除它,因为我打开了一个新终端,并且版本2.3.7不断出现。

    rails cRunning via Spring preloader in process 42876
    /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require': dlopen(/Users/adriantapia/.rvm/rubies/ruby-2.4.4/lib/ruby/2.4.0/x86_64-darwin18/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib (LoadError)
      Referenced from: /Users/adriantapia/.rvm/rubies/ruby-2.4.4/lib/ruby/2.4.0/x86_64-darwin18/readline.bundle
      Reason: image not found - /Users/adriantapia/.rvm/rubies/ruby-2.4.4/lib/ruby/2.4.0/x86_64-darwin18/readline.bundle
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `block in require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:258:in `load_dependency'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require'
            from /Users/adriantapia/.rvm/rubies/ruby-2.4.4/lib/ruby/2.4.0/irb/completion.rb:10:in `<top (required)>'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `block in require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:258:in `load_dependency'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/commands/console/console_command.rb:2:in `<top (required)>'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `block in require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:258:in `load_dependency'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/command/behavior.rb:82:in `block (2 levels) in lookup'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/command/behavior.rb:78:in `each'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/command/behavior.rb:78:in `block in lookup'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/command/behavior.rb:77:in `each'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/command/behavior.rb:77:in `lookup'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/command.rb:68:in `find_by_namespace'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/command.rb:42:in `invoke'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/commands.rb:16:in `<top (required)>'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `block in require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:258:in `load_dependency'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require'
            from /Users/adriantapia/Desktop/Proyectos/first_web/bin/rails:9:in `<top (required)>'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:286:in `load'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:286:in `block in load'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:258:in `load_dependency'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:286:in `load'
            from /Users/adriantapia/.rvm/rubies/ruby-2.4.4/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:59:in `require'
            from /Users/adriantapia/.rvm/rubies/ruby-2.4.4/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:59:in `require'
            from -e:1:in `<main>'
    Adrians-MacBook-Pro:first_web adriantapia$ rails c
    Running via Spring preloader in process 43094
    /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require': dlopen(/Users/adriantapia/.rvm/rubies/ruby-2.4.4/lib/ruby/2.4.0/x86_64-darwin18/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib (LoadError)
      Referenced from: /Users/adriantapia/.rvm/rubies/ruby-2.4.4/lib/ruby/2.4.0/x86_64-darwin18/readline.bundle
      Reason: image not found - /Users/adriantapia/.rvm/rubies/ruby-2.4.4/lib/ruby/2.4.0/x86_64-darwin18/readline.bundle
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `block in require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:258:in `load_dependency'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require'
            from /Users/adriantapia/.rvm/rubies/ruby-2.4.4/lib/ruby/2.4.0/irb/completion.rb:10:in `<top (required)>'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `block in require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:258:in `load_dependency'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/commands/console/console_command.rb:2:in `<top (required)>'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `block in require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:258:in `load_dependency'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/command/behavior.rb:82:in `block (2 levels) in lookup'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/command/behavior.rb:78:in `each'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/command/behavior.rb:78:in `block in lookup'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/command/behavior.rb:77:in `each'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/command/behavior.rb:77:in `lookup'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/command.rb:68:in `find_by_namespace'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/command.rb:42:in `invoke'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/railties-5.1.6.1/lib/rails/commands.rb:16:in `<top (required)>'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `block in require'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:258:in `load_dependency'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:292:in `require'
            from /Users/adriantapia/Desktop/Proyectos/first_web/bin/rails:9:in `<top (required)>'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:286:in `load'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:286:in `block in load'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:258:in `load_dependency'
            from /Users/adriantapia/.rvm/gems/ruby-2.4.4/gems/activesupport-5.1.6.1/lib/active_support/dependencies.rb:286:in `load'
            from /Users/adriantapia/.rvm/rubies/ruby-2.4.4/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:59:in `require'
            from /Users/adriantapia/.rvm/rubies/ruby-2.4.4/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:59:in `require'
            from -e:1:in `<main>'


My RVM: rvm list
   ruby-2.4.1 [ x86_64 ]
=* ruby-2.4.4 [ x86_64 ]
   ruby-2.5.1 [ x86_64 ]

ruby -v :
    ruby 2.4.4p296 (2018-03-28 revision 63013) [x86_64-darwin18]

rails -v:
Rails 5.1.6.1

3 个答案:

答案 0 :(得分:1)

您可能针对libreadline.7.dylib编译了Ruby版本,但是最近更新到了libreadline.8.dylib –例如,通过运行brew upgrade

现在,Ruby抱怨它在libreadline.7.dylib文件夹中找不到/usr/local/opt/readline/lib/

修复:导航到该文件夹​​并列出其内容

$ cd /usr/local/opt/readline/lib/
$ ls -l

您可能会看到以下内容:

... libreadline.8.0.dylib
... libreadline.8.dylib -> libreadline.8.0.dylib

然后为丢失的旧版本创建一个新的符号链接:

$ ln -s libreadline.8.0.dylib libreadline.7.dylib

答案 1 :(得分:0)

如果使用RVM,则可以将ruby版本设置为每个特定的ruby项目。您转到项目文件夹,然后键入:

GET MAX ID

然后选择该项目所需的红宝石版本:

GET MAX ID

要在任何新项目上或未设置本地版本的地方设置默认RVM版本:

rvm list
#will return list of all installed rubies and which one you're currently using, for example:

   ruby-2.1.10 [ x86_64 ]
   ruby-2.1.2 [ x86_64 ]
   ruby-2.3.4 [ x86_64 ]
   ruby-2.3.5 [ x86_64 ]
   ruby-2.3.6 [ x86_64 ]
   ruby-2.3.7 [ x86_64 ]
=* ruby-2.4.1 [ x86_64 ]
   ruby-2.5.1 [ x86_64 ]
   ruby-2.6.1 [ x86_64 ]

在Rails项目的Gemfile中,您还可以设置ruby版本,您应该有如下一行:

rvm use 2.6.1 # will set RVM to use this version locally from this directory

对于每个红宝石版本,如果是第一次将它与该红宝石版本一起使用以为该项目安装gem,则可能需要在rails项目上至少运行一次。

rvm use 2.6.1 --default

有关更多信息,请参见How to set default Ruby version with RVM?

答案 2 :(得分:0)

由于春季问题,这也是可能的。尝试使用以下命令重新启动它:

bin/spring stop

bin/spring start