Skip to content
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

NoMethodError: undefined method `[]' for nil:NilClass #90

Open
jacob-carlborg opened this issue Sep 4, 2015 · 1 comment
Open

NoMethodError: undefined method `[]' for nil:NilClass #90

jacob-carlborg opened this issue Sep 4, 2015 · 1 comment

Comments

@jacob-carlborg
Copy link
Contributor

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:

  1. Generating a new Rails application with Rails 4.1.9: rails new foo
  2. Generating a new model with a migration rails g model Bar foo:string
  3. Running the migrations rake db:migrate
  4. Adding a method_missing to Bar like this:
class Bar < ActiveRecord::Base
  def method_missing symbol, *args
    self.foo
  end
end
  1. Starting the rails console rails c
  2. Invoking pry pry
  3. 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'
@vincentwoo
Copy link
Collaborator

Also seeing a similar issue here: #66 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants