简体   繁体   中英

Unable to Execute Rails console command Ruby

/Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/completion.rb:10:in `require': dlopen(/Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
  Referenced from: /Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
  Reason: image not found - /Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
    from /Users/parkerharris/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/irb/completion.rb:10:in `<top (required)>'
    from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/console.rb:3:in `require'
    from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/console.rb:3:in `<top (required)>'
    from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:138:in `require'
    from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:138:in `require_command!'
    from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
    from /Users/parkerharris/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

This is my error screen after trying to execute the command. I've tried to uninstall and reinstall readline and that did not help. I am just learning rails and do not 100% know what I am doing (just following a guide) so this type of error is past my understanding. Thanks!

Might not be related, but I had the same thing happen to me today.

I had a fully-functioning Ruby 2.3.1 working fine this morning. In my case, Ruby was compiled and installed by ruby-build and managed by rbenv.

At one point today I updated Homebrew with

brew cleanup --prune=30
brew update
brew upgrade

One of the formulae upgraded was readline 7.0:

$ brew info readline
...
/usr/local/Cellar/readline/7.0 (45 files, 2M)
  Poured from bottle on 2016-10-05 at 08:09:22

Shortly afterwords I found that my readline support for Ruby had become completely broken. I saw errors just like yours:

/Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.4/lib/pry/config/default.rb:151:in `require': dlopen(/Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle, 9): Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib (LoadError)
  Referenced from: /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
  Reason: image not found - /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/2.3.0/x86_64-darwin15/readline.bundle
  from /Users/mbrictson/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pry-0.10.4/lib/pry/config/default.rb:151:in `lazy_readline'

The solution was to completely delete my Ruby installation and recompile it:

rm -rf ~/.rbenv/versions/2.3.1
rbenv install 2.3.1

I know you are using rvm and not rbenv, but perhaps the solution in your case is similar: delete your Ruby installation and re-install it using rvm.

A really fast and quick solution is to add rb-readline to your Gemfile. (In case the other solutions don't work and you want to move on until you have time to address the issue. I know it this is not ideal but it is a working solution.)

In the GemFile:

group :development do gem 'rb-readline' end

Now, just bundle install. I found this solution on Option 4 at ( https://github.com/guard/guard/wiki/Add-Readline-support-to-Ruby-on-Mac-OS-X ) I hope it helps.

There's something wrong with your rvm , it doesn't seems to be related with rails. Please verify if it's installed properly.

Ensure that you've checked the rvm prerequisites on https://rvm.io/rvm/prerequisites

and that your install is working properly, eg

(from: https://rvm.io/rvm/install ) If installation and configuration were successful, RVM should now load whenever you open a new shell. This can be tested by executing the following command which should output rvm is a function as shown below.

$ type rvm | head -n 1
rvm is a function

Check on your mac if readline has been properly compiled, or try to do a clean install ruby-2.3.0 again

You can check on RVM regarding the package and autolibs on: https://rvm.io/packages/readline

I had similar issue. My Ruby was installed using HomeBrew. In my case I needed to uninstall Ruby; install/link libyaml; and then reinstall ruby.

brew uninstall ruby
brew link libyaml
brew install ruby

Same thing happened to me when I unwittingly ran rvm requirements after installing ruby 2.3.1.

rvm uninstall 2.3.1
rvm   install 2.3.1

Above fixed it.

Running this from the command line worked for me:

ln -s /usr/local/opt/readline/lib/libreadline.7.0.dylib /usr/local/opt/readline/lib/libreadline.6.dylib

from github

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM