error with pry- warning: already initialized const

2019-08-03 07:02发布

问题:

I have used pry in the terminal all year long without any problem. But starting last night, every time I type pry in the terminal, it doesn't open and instead gives me a long log of errors. I tried several things and spent a lot of time searching but I am at lost and don't know what to do next. I don't understand why it gives me some line numbers of a ruby file with the different errors since it usually work without being related to a file. The log is a bit long, but the errors get repeated. I put everything in case it was important. I would very much appreciate some guidance.

Last login: Wed Jul 23 10:35:32 on console
You have mail.
Sylvies-MacBook-Air:~ sylviecottrell$ pry
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:14: warning: already initialized constant Pry::DEFAULT_HOOKS
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:14: warning: previous definition of DEFAULT_HOOKS was here
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:20: warning: already initialized constant Pry::DEFAULT_PRINT
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:20: warning: previous definition of DEFAULT_PRINT was here
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:29: warning: already initialized constant Pry::SIMPLE_PRINT
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:29: warning: previous definition of SIMPLE_PRINT was here
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:38: warning: already initialized constant Pry::CLIPPED_PRINT
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:38: warning: previous definition of CLIPPED_PRINT was here
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:43: warning: already initialized constant Pry::DEFAULT_EXCEPTION_HANDLER
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:43: warning: previous definition of DEFAULT_EXCEPTION_HANDLER was here
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:52: warning: already initialized constant Pry::DEFAULT_PROMPT_NAME
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:52: warning: previous definition of DEFAULT_PROMPT_NAME was here
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:55: warning: already initialized constant Pry::DEFAULT_PROMPT
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:55: warning: previous definition of DEFAULT_PROMPT was here
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:65: warning: already initialized constant Pry::DEFAULT_PROMPT_SAFE_OBJECTS
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:65: warning: previous definition of DEFAULT_PROMPT_SAFE_OBJECTS was here
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:68: warning: already initialized constant Pry::SIMPLE_PROMPT
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:68: warning: previous definition of SIMPLE_PROMPT was here
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:70: warning: already initialized constant Pry::NO_PROMPT
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:70: warning: previous definition of NO_PROMPT was here
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:72: warning: already initialized constant Pry::SHELL_PROMPT
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:72: warning: previous definition of SHELL_PROMPT was here
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:79: warning: already initialized constant Pry::NAV_PROMPT
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:79: warning: previous definition of NAV_PROMPT was here
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:94: warning: already initialized constant Pry::DEFAULT_CONTROL_D_HANDLER
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:94: warning: previous definition of DEFAULT_CONTROL_D_HANDLER was here
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:109: warning: already initialized constant Pry::DEFAULT_SYSTEM
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:109: warning: previous definition of DEFAULT_SYSTEM was here
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:117: warning: already initialized constant Pry::INITIAL_PWD
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:117: warning: previous definition of INITIAL_PWD was here
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry/cli.rb:6: warning: already initialized constant Pry::CLI::NoOptionsError
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry/cli.rb:6: warning: previous definition of NoOptionsError was here
/usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:1998:in `raise_if_conflicts': Unable to activate pry-byebug-1.3.2, because pry-0.10.0 conflicts with pry (~> 0.9.12) (Gem::LoadError)
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:1235:in `activate'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems.rb:194:in `rescue in try_activate'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems.rb:191:in `try_activate'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:132:in `rescue in require'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
    from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-byebug-1.3.2/lib/pry-byebug/cli.rb:1:in `<top (required)>'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry/plugins.rb:38:in `load_cli_options'
    from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry/cli.rb:40:in `block in add_plugin_options'
    from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry/cli.rb:39:in `each'
    from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry/cli.rb:39:in `add_plugin_options'
    from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry/cli.rb:107:in `<top (required)>'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/lib/pry.rb:150:in `<top (required)>'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/bin/pry:12:in `rescue in <top (required)>'
    from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/pry-0.10.0/bin/pry:8:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/pry:23:in `load'
    from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/pry:23:in `<main>'
    from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `eval'
    from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `<main>'
Sylvies-MacBook-Air:~ sylviec

回答1:

Pry went from version 9.12 to version 10 recently, and it seems the update created an incompatibility with bye-bug or pry-nav... One of the two. I've gotten around this by reverting back to Pry version 9.12. You can do this by typing...

gem uninstall pry

It'll ask you which version to uninstall, you'll want to uninstall version '10.' If it doesn't ask you and you uninstall Pry entirely, you can get it right back with...

gem install pry -v 0.9.12

Hope this helps.