New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pry doesn't show code when prepended modules are used #1471

Closed
jodosha opened this Issue Sep 15, 2015 · 36 comments

Comments

Projects
None yet
@jodosha

jodosha commented Sep 15, 2015

Hello, Lotus users can't make their fav debug tool to work with their apps (see hanami/hanami#205). I've isolated the problem.

# foo.rb
require 'minitest/autorun'
require 'pry'

module CoolFeature
  def self.included(base)
    base.class_eval do
      prepend InstanceMethods
    end
  end

  module InstanceMethods
    def bar
      puts "before"
      super
      puts "after"
    end
  end
end

class Foo
  include CoolFeature

  def bar
    puts "inside"
    binding.pry
  end
end

describe Foo do
  it "uses #bar" do
    Foo.new.bar
  end
end

Then, if you run the test:

ruby foo.rb

It stops where the breakpoint is, but it doesn't show the code:

screen shot 2015-09-15 at 15 30 17

When I press ^C it becomes:

screen shot 2015-09-15 at 15 31 04

If I run the tests via Rake, it changes a little bit:

# Rakefile
require 'rake'
require 'rake/testtask'

Rake::TestTask.new do |t|
  t.pattern = '**/*.rb'
  # t.libs    << 'spec'
end

task default: :test
task spec: :test

And then:

bundle exec rake

It behaves exactly the same, BUT when I type any button on the keyboard, it prints a stack trace:

~/Desktop/show-me-the-code:ruby-2.2.3 ➜ bundle exec rakeError: Input/output error - read
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:198:in `readline'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:198:in `block in input_readline'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:115:in `call'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:115:in `interruptible_region'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:197:in `input_readline'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:183:in `block in read_line'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:129:in `handle_read_errors'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:170:in `read_line'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:98:in `read'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:68:in `block in repl'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:67:in `loop'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:67:in `repl'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:38:in `block in start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:61:in `call'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:61:in `__with_ownership'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:79:in `with_ownership'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:38:in `start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:15:in `start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/pry_class.rb:169:in `start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/core_extensions.rb:43:in `pry'
/Users/luca/Desktop/show-me-the-code/foo.rb:25:in `bar'
/Users/luca/Desktop/show-me-the-code/foo.rb:14:in `bar'
/Users/luca/Desktop/show-me-the-code/foo.rb:31:in `block (2 levels) in <top (required)>'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:108:in `block (3 levels) in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:205:in `capture_exceptions'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:105:in `block (2 levels) in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:256:in `time_it'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:104:in `block in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:334:in `on_signal'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:276:in `with_info_handler'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:103:in `run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:781:in `run_one_method'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:308:in `run_one_method'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:296:in `block (2 levels) in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:295:in `each'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:295:in `block in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:334:in `on_signal'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:321:in `with_info_handler'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:294:in `run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:155:in `block in __run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:155:in `map'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:155:in `__run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:129:in `run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:56:in `block in autorun'
[1] pry(#<Foo>)> Error: Input/output error - read
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:198:in `readline'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:198:in `block in input_readline'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:115:in `call'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:115:in `interruptible_region'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:197:in `input_readline'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:183:in `block in read_line'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:129:in `handle_read_errors'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:170:in `read_line'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:98:in `read'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:68:in `block in repl'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:67:in `loop'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:67:in `repl'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:38:in `block in start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:61:in `call'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:61:in `__with_ownership'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:79:in `with_ownership'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:38:in `start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:15:in `start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/pry_class.rb:169:in `start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/core_extensions.rb:43:in `pry'
/Users/luca/Desktop/show-me-the-code/foo.rb:25:in `bar'
/Users/luca/Desktop/show-me-the-code/foo.rb:14:in `bar'
/Users/luca/Desktop/show-me-the-code/foo.rb:31:in `block (2 levels) in <top (required)>'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:108:in `block (3 levels) in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:205:in `capture_exceptions'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:105:in `block (2 levels) in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:256:in `time_it'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:104:in `block in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:334:in `on_signal'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:276:in `with_info_handler'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:103:in `run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:781:in `run_one_method'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:308:in `run_one_method'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:296:in `block (2 levels) in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:295:in `each'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:295:in `block in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:334:in `on_signal'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:321:in `with_info_handler'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:294:in `run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:155:in `block in __run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:155:in `map'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:155:in `__run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:129:in `run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:56:in `block in autorun'
[1] pry(#<Foo>)> Error: Input/output error - read
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:198:in `readline'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:198:in `block in input_readline'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:115:in `call'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:115:in `interruptible_region'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:197:in `input_readline'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:183:in `block in read_line'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:129:in `handle_read_errors'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:170:in `read_line'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:98:in `read'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:68:in `block in repl'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:67:in `loop'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:67:in `repl'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:38:in `block in start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:61:in `call'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:61:in `__with_ownership'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:79:in `with_ownership'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:38:in `start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:15:in `start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/pry_class.rb:169:in `start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/core_extensions.rb:43:in `pry'
/Users/luca/Desktop/show-me-the-code/foo.rb:25:in `bar'
/Users/luca/Desktop/show-me-the-code/foo.rb:14:in `bar'
/Users/luca/Desktop/show-me-the-code/foo.rb:31:in `block (2 levels) in <top (required)>'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:108:in `block (3 levels) in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:205:in `capture_exceptions'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:105:in `block (2 levels) in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:256:in `time_it'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:104:in `block in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:334:in `on_signal'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:276:in `with_info_handler'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:103:in `run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:781:in `run_one_method'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:308:in `run_one_method'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:296:in `block (2 levels) in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:295:in `each'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:295:in `block in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:334:in `on_signal'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:321:in `with_info_handler'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:294:in `run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:155:in `block in __run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:155:in `map'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:155:in `__run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:129:in `run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:56:in `block in autorun'
[1] pry(#<Foo>)> Error: Input/output error - read
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:198:in `readline'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:198:in `block in input_readline'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:115:in `call'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:115:in `interruptible_region'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:197:in `input_readline'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:183:in `block in read_line'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:129:in `handle_read_errors'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:170:in `read_line'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:98:in `read'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:68:in `block in repl'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:67:in `loop'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:67:in `repl'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:38:in `block in start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:61:in `call'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:61:in `__with_ownership'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:79:in `with_ownership'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:38:in `start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:15:in `start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/pry_class.rb:169:in `start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/core_extensions.rb:43:in `pry'
/Users/luca/Desktop/show-me-the-code/foo.rb:25:in `bar'
/Users/luca/Desktop/show-me-the-code/foo.rb:14:in `bar'
/Users/luca/Desktop/show-me-the-code/foo.rb:31:in `block (2 levels) in <top (required)>'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:108:in `block (3 levels) in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:205:in `capture_exceptions'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:105:in `block (2 levels) in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:256:in `time_it'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:104:in `block in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:334:in `on_signal'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:276:in `with_info_handler'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:103:in `run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:781:in `run_one_method'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:308:in `run_one_method'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:296:in `block (2 levels) in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:295:in `each'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:295:in `block in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:334:in `on_signal'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:321:in `with_info_handler'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:294:in `run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:155:in `block in __run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:155:in `map'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:155:in `__run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:129:in `run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:56:in `block in autorun'
[1] pry(#<Foo>)> Error: Input/output error - read
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:198:in `readline'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:198:in `block in input_readline'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:115:in `call'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:115:in `interruptible_region'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:197:in `input_readline'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:183:in `block in read_line'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:129:in `handle_read_errors'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:170:in `read_line'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:98:in `read'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:68:in `block in repl'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:67:in `loop'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:67:in `repl'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:38:in `block in start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:61:in `call'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:61:in `__with_ownership'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/input_lock.rb:79:in `with_ownership'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:38:in `start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/repl.rb:15:in `start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/pry_class.rb:169:in `start'
/Users/luca/.gem/ruby/2.2.3/gems/pry-0.10.1/lib/pry/core_extensions.rb:43:in `pry'
/Users/luca/Desktop/show-me-the-code/foo.rb:25:in `bar'
/Users/luca/Desktop/show-me-the-code/foo.rb:14:in `bar'
/Users/luca/Desktop/show-me-the-code/foo.rb:31:in `block (2 levels) in <top (required)>'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:108:in `block (3 levels) in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:205:in `capture_exceptions'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:105:in `block (2 levels) in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:256:in `time_it'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:104:in `block in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:334:in `on_signal'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:276:in `with_info_handler'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest/test.rb:103:in `run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:781:in `run_one_method'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:308:in `run_one_method'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:296:in `block (2 levels) in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:295:in `each'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:295:in `block in run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:334:in `on_signal'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:321:in `with_info_handler'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:294:in `run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:155:in `block in __run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:155:in `map'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:155:in `__run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:129:in `run'
/Users/luca/.gem/ruby/2.2.3/gems/minitest-5.8.0/lib/minitest.rb:56:in `block in autorun'
FATAL: Pry failed to get user input using `Readline`.
To fix this you may be able to pass input and output file descriptors to pry directly. e.g.
  Pry.config.input = STDIN
  Pry.config.output = STDOUT
  binding.pry

after
.

Finished in 3.216081s, 0.3109 runs/s, 0.0000 assertions/s.

1 runs, 0 assertions, 0 failures, 0 errors, 0 skips

@jodosha jodosha changed the title from Pry doesn't show code for when prepended modules are used to Pry doesn't show code when prepended modules are used Sep 15, 2015

@banister

This comment has been minimized.

Member

banister commented Sep 16, 2015

@jodosha thanks for the thorough investigation, this is very interesting! Pry hasn't quite caught up with the times yet in terms of some of the new ruby 2 features, including prepended modules and refinements (though we do have some support for refinements iirc).

I'll try to take a look at this this weekend. I know we do have some reasonable assumptions about the ancestor chain such as the 0th ancestor of a class being 'self', but this assumption is now broken by prepending functionality, fun. :)

@jodosha

This comment has been minimized.

jodosha commented Sep 21, 2015

@banister I understand this can be a tricky issue to fix. Did you had the chance to have a look at it? Thank you in advance for this and for Pry in general. 🎩

@talitore

This comment has been minimized.

talitore commented Sep 22, 2015

@jodosha While I haven't found a fix yet, I've found what looks to be the root cause.

If you look at the source here: https://github.com/pry/pry/blob/master/lib/pry/method.rb#L382; you'll see that there's a method named #super which is somehow in scope of InstanceMethods#bar when it's being evaluated. This is causing an endless loop of evaluation and creation of Pry::Method.new(sup) objects.

Hopefully that points someone into the right direction.

@banister

This comment has been minimized.

Member

banister commented Sep 22, 2015

@talitore Unfortunately that can't be the reason cos the super keyword would override any method of the same name when it's called, so i don't think it can be due to the super method going into a loop.. :(

@jodosha Sorry i didn't suggest this earlier, but i just tried your code on pry master and it works without problems. So whatever the problem is, it appears it's now fixed on master! Please double check to confirm! :)

@r-obert

This comment has been minimized.

Member

r-obert commented Sep 22, 2015

seems fixed for me too.

v0.10.1 (broken)

ruby testing1.rb 
Run options: --seed 9768

# Running tests:

before
inside

HEAD (works)

ruby testing1.rb
# Running tests:

before
inside

From: /Users/strcmp/pry/testing1.rb @ line 26 CoolFeature::InstanceMethods#bar:

    21: class Foo
    22:   include CoolFeature
    23: 
    24:   def bar
    25:     puts "inside"
 => 26:     binding.pry
    27:   end
    28: end
    29: 
    30: describe Foo do
    31:   it "uses #bar" do
@jodosha

This comment has been minimized.

jodosha commented Sep 22, 2015

Please double check to confirm! :)

@banister @strcmp @talitore It works with master!!
Thank you for your quick reply and fix. 🎩

Do you have plans to release it soon? That would unlock a lot of devs that want to use Pry with Lotus.

@jodosha jodosha closed this Sep 22, 2015

@r-obert

This comment has been minimized.

Member

r-obert commented Sep 22, 2015

@jodosha yeah I think we would like to cut a new release soon. not sure but i think we want ConradIrwin/pry-rescue#84 to be merged first. @ConradIrwin

@banister

This comment has been minimized.

Member

banister commented Sep 25, 2015

@jodosha just cut a new release now (0.10.2) It's just built on the current 0.10.1 release and doesnt include commits from master EXCEPT th eone i cherry-picked specifically for fixing your bug. Let me know if it works!

@jodosha

This comment has been minimized.

jodosha commented Sep 25, 2015

@banister Awesome! I've pinged the rest of the folks in that Lotus ticket. It works for me! 👍 Thank you very much, I appreciated it.

@nestegg

This comment has been minimized.

nestegg commented Oct 12, 2015

I'm still having this issue. While it does appear to have fixed it in tests, elsewhere in the stack, specifically in controller actions, it is still hanging.

@r-obert

This comment has been minimized.

Member

r-obert commented Oct 13, 2015

@nestegg do you have a reproducible example we could use?

@nestegg

This comment has been minimized.

nestegg commented Oct 13, 2015

@jodosha

This comment has been minimized.

jodosha commented Oct 14, 2015

@strcmp @nestegg I can confirm the problem.

rossta added a commit to rossta/github_groove that referenced this issue Feb 22, 2016

@rossta rossta referenced this issue Feb 22, 2016

Open

Pry issue #7

@rossta

This comment has been minimized.

rossta commented Feb 22, 2016

I am seeing this issue in recent versions of pry-0.10.3 and pry-byebug-3.3.0 with hanami-0.7.0.

@lasseebert

This comment has been minimized.

lasseebert commented Mar 31, 2016

Same error here. Tried pry 0.10.3, 0.10.2 and master, but all of them "hang" in the action call method (the one using prepend).

Did anyone got this to work on 0.10.2?

@toovs

This comment has been minimized.

toovs commented Apr 3, 2016

also hanging in the action call over here

@outsmartin

This comment has been minimized.

outsmartin commented May 31, 2016

Having the same issue here.

@kevinjalbert

This comment has been minimized.

kevinjalbert commented Sep 8, 2016

Just wanted to add to this. I had this issue on pry version 0.10.1. I updated to version 0.10.4 and it works now.

@lasseebert

This comment has been minimized.

lasseebert commented Sep 12, 2016

I still have the issue in my Hanami application. However it seems that a small example app works just fine:
This small example is not working on 0.10.1 but is working on 0.10.2, 0.10.3 and 0.10.4:

Anyone still having the problem in some cases that can reproduce the issue in a small example?

require "pry"

module PrependThis
  def foo
    super + 1
  end
end

class Foo
  prepend PrependThis

  def foo
    binding.pry
    2
  end
end

puts Foo.new.foo
@lasseebert

This comment has been minimized.

lasseebert commented Sep 12, 2016

Ok, I successfully reproduced this on 0.10.4 with two prepends:

require "pry"

module PrependThis
  def foo
    super + 1
  end
end

module AlsoPrependThis
  def foo
    super + 2
  end
end

class Foo
  prepend PrependThis
  prepend AlsoPrependThis

  def foo
    binding.pry
    4
  end
end

puts Foo.new.foo
@Fedcomp

This comment has been minimized.

Fedcomp commented Nov 3, 2017

Guys, any progress on this? really breaker for using hanami to me.

@r-obert r-obert self-assigned this Nov 4, 2017

@r-obert

This comment has been minimized.

Member

r-obert commented Nov 4, 2017

No progress yet sorry but I have some time on my hands so I'll take a look.

@banister

This comment has been minimized.

Member

banister commented Nov 4, 2017

@r-obert that would be awesome, I think it's due to a deep assumption in pry that the zeroeth ancestor should always be the class itself,which prepending breaks. Hopefully it's encapsulated in one place in the code and not spread around, however if it is spread around this could be a nice opportunity to refactor.

@r-obert r-obert added the important label Nov 7, 2017

r-obert added a commit to r-obert/pry that referenced this issue Nov 7, 2017

Fix pry#1471
Avoid an infinite loop by detecting a method that has been prepended.
@r-obert

This comment has been minimized.

Member

r-obert commented Nov 7, 2017

@Fedcomp Could you try the branch or diff from #1689 ?

r-obert added a commit to r-obert/pry that referenced this issue Nov 8, 2017

fix pry#1471, fix pry#1621
Avoid a case of infinite recursion while searching for a superclass
by first checking if 'self' has been altered using Ruby2 'prepend'
feature. In this case, we do not search for an ancestor since the
owner of the method is a prepended module.

r-obert added a commit to r-obert/pry that referenced this issue Nov 8, 2017

fix pry#1471, fix pry#1621
Abort early when searching for a superclass if the target method
has been called through 'super' keyword from a prepended module.

@r-obert r-obert referenced this issue Nov 8, 2017

Merged

fix #1471, fix #1621 #1689

3 of 3 tasks complete

@r-obert r-obert closed this in 6a89f57 Nov 11, 2017

@jodosha

This comment has been minimized.

jodosha commented Nov 11, 2017

r-obert added a commit to r-obert/pry that referenced this issue Nov 13, 2017

fix pry#1471, fix pry#1621 (pry#1689)
* Abort early when searching for a superclass if the target method
has been called through 'super' keyword from a prepended module.

* mv spec/regression spec/integration

* add hanami integration spec
@banister

This comment has been minimized.

Member

banister commented Nov 23, 2017

Can anyone here confirm whether the recent pry version actually fixes the hanami issue?

@r-obert

This comment has been minimized.

Member

r-obert commented Nov 23, 2017

I confirmed with a sample app provided in another issue @banister but yeah it would be nice to get second word that it is fixed.

@Fedcomp

This comment has been minimized.

Fedcomp commented Nov 23, 2017

@r-obert with the most recent version i can see hanami action
image

@r-obert

This comment has been minimized.

Member

r-obert commented Nov 23, 2017

cool, thanks. i guess you're using pry-byebug?

@Fedcomp

This comment has been minimized.

Fedcomp commented Nov 23, 2017

@r-obert correct. From Gemfile.lock:

    pry (0.11.3)
      coderay (~> 1.1.0)
      method_source (~> 0.9.0)
    pry-byebug (3.5.0)
      byebug (~> 9.1)
      pry (~> 0.10)
@r-obert

This comment has been minimized.

Member

r-obert commented Nov 23, 2017

thanks, that explains __LINE__ + 1. so is it working to your satisfaction?

@Fedcomp

This comment has been minimized.

Fedcomp commented Nov 23, 2017

Yeah it's amazing, thank you 🎉
It was real pain to deal with, i had to make additional method to debug it.

@r-obert

This comment has been minimized.

Member

r-obert commented Nov 23, 2017

Great to hear. Thanks for your help.

@Fedcomp

This comment has been minimized.

Fedcomp commented Nov 23, 2017

nah, i should thank you instead. It's really helpful fix. It feelt kinda disaster when you can't use instrument you love as you used to use it.

@banister

This comment has been minimized.

Member

banister commented Nov 23, 2017

Nice work @r-obert! 😍💰🐙

@r-obert

This comment has been minimized.

Member

r-obert commented Nov 23, 2017

no problem 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment