I've run in to an issue with Pry resulting an internal exception. The error only occurs when pry-rescue is loaded. I've been able to reproduce the issue by:
Generating a new Rails application with Rails 4.1.9: rails new foo
Generating a new model with a migration rails g model Bar foo:string
Running the migrations rake db:migrate
Adding a method_missing to Bar like this:
class Bar < ActiveRecord::Base
def method_missing symbol, *args
self.foo
end
end
Starting the rails console rails c
Invoking pry pry
Running the following Bar.new(foo: "asd")
The full stack trace looks like this:
NoMethodError: undefined method `[]' for nil:NilClass
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/last_exception.rb:54:in `bt_source_location_for'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/last_exception.rb:15:in `initialize'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/pry_instance.rb:494:in `new'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/pry_instance.rb:494:in `last_exception='
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/pry_instance.rb:331:in `rescue in handle_line'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/pry_instance.rb:317:in `handle_line'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/pry_instance.rb:243:in `block (2 levels) in eval'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/pry_instance.rb:242:in `catch'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/pry_instance.rb:242:in `block in eval'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/pry_instance.rb:241:in `catch'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/pry_instance.rb:241:in `eval'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/repl.rb:77:in `block in repl'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/repl.rb:67:in `loop'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/repl.rb:67:in `repl'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/repl.rb:38:in `block in start'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/input_lock.rb:61:in `call'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/input_lock.rb:61:in `__with_ownership'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/input_lock.rb:79:in `with_ownership'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/repl.rb:38:in `start'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/repl.rb:15:in `start'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/pry_class.rb:169:in `start'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/pry-0.10.1/lib/pry/core_extensions.rb:43:in `pry'
from (irb):1
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/railties-4.1.9/lib/rails/commands/console.rb:90:in `start'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/railties-4.1.9/lib/rails/commands/console.rb:9:in `start'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/railties-4.1.9/lib/rails/commands/commands_tasks.rb:69:in `console'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/railties-4.1.9/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /Users/jacob/.rvm/gems/ruby-2.1.5@foo/gems/railties-4.1.9/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:8:in `require'
I've run in to an issue with Pry resulting an internal exception. The error only occurs when pry-rescue is loaded. I've been able to reproduce the issue by:
rails new foo
rails g model Bar foo:string
rake db:migrate
method_missing
toBar
like this:rails c
pry
Bar.new(foo: "asd")
The full stack trace looks like this: