Search code examples
rubypry

Requiring pry gem into ruby script causes error


I am using ruby version 2.3.3p222

Here is my Gemfile:

# Gemfile
source 'https://rubygems.org'

gem 'pry'

I run bundle and here is the resulting Gemfile.lock

Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    coderay (1.1.2)
    method_source (0.9.2)
    pry (0.12.2)
      coderay (~> 1.1.0)
      method_source (~> 0.9.0)

PLATFORMS
  ruby

DEPENDENCIES
  pry

BUNDLED WITH
   1.15.1

I then simply run a ruby script via ruby my_report.rb (this script is located in the same directory as Gemfile and Gemfile.lock). my_report.rb only has this in the file:

require 'pry'

Here is the error:

WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
/Users/<user>/.rvm/gems/ruby-2.3.3/gems/pry-rescue-1.4.5/lib/pry-rescue.rb:15: warning: method BaseHelpers#windows? is deprecated. Use Pry:Helpers::Platform.windows? instead
/Users/<user>/.rvm/gems/ruby-2.3.3/gems/pry-stack_explorer-0.4.9.2/lib/pry-stack_explorer.rb:128:in `<top (required)>': undefined method `before_command' for #<Pry::CommandSet:0x007fccdcf0b1e8> (NoMethodError)

Question: What am I missing? How can I properly require in pry into my ruby script so that I can set breakpoints?


Solution

  • What eventually worked for me is I just uninstalled all of the pry versions I had installed via gem uninstall. Then: in my gemfile I specified a previous version of 0.11.3:

    # Gemfile
    source 'https://rubygems.org'
    gem 'pry', '0.11.3'
    

    I did bundle install and then ran my ruby script, and that worked for me.