Can't escape from eval with next using Pry-rails
Asked Answered
A

5

49

Hi I've installed Pry to do some awesome debugging and had it working before but when I step into the code with 'next' I get the following error:

SyntaxError: (eval):2: Can't escape from eval with next

Code being used:

def create
    binding.pry
    build_resource(sign_up_params)

    if resource.save
      yield resource if block_given?
      if resource.active_for_authentication?
        set_flash_message :notice, :signed_up if is_flashing_format?
        sign_up(resource_name, resource)
        respond_with resource, :location => after_sign_up_path_for(resource)
      else
        set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
        expire_data_after_sign_in!
        respond_with resource, :location => after_inactive_sign_up_path_for(resource)
      end
    else
      clean_up_passwords resource
      respond_with resource
    end
  end

Has anyone else had this issue?

Adama answered 5/12, 2013 at 15:42 Comment(6)
i think it's saying that you placed debugger inside a block that's being passed to evalChristogram
What does that mean to eval?Adama
can you paste the code where you added binding.pry?Christogram
i have no idea. a quick google of the error shows an unresolved ticket github.com/nixme/pry-nav/issues/20Christogram
Yeah I saw that as well, so confused, I love PRY but I cannot use it I get the same issue everytime I put it inAdama
try specifying a specific gem version and see what works.Christogram
P
71

Please make sure to install the 'pry-nav' gem.

I had the same error because I made the assumption that navigation commands were included into the 'pry-rails' gem.

Add gem 'pry-nav' in your Gemfile, then run bundle install.

Prakash answered 1/4, 2014 at 16:21 Comment(3)
How is this answer not everywhere?Voyage
On pry-nav pages it is now suggested to use pry-byebug gem (for Ruby >= 2.0) or pry-debugger gem (for Ruby <= 1.9).Shannan
Didn't work for me. I still have the same problem.Ravenous
S
28

You can now use pry-byebug gem (for Ruby >= 2.0) or pry-debugger gem (for Ruby <= 1.9).

Use it together with pry gem in your Gemfile:

# Gemfile
gem 'pry'
gem 'pry-byebug'
Shannan answered 22/6, 2016 at 18:13 Comment(0)
B
1

I had a similar issue, in my case the problem was solved because I needed to require those gems. For example:

group :development, :test do
  ...
  gem 'pry',                                require: true
  gem 'pry-byebug',                         require: true
  gem 'pry-doc',                            require: true
  gem 'rspec-rails',                        require: false
  ...
end
Bivens answered 9/12, 2021 at 20:59 Comment(0)
R
1

This is what solved the problem. Even the answer here didn't work for me.

I had to add require 'pry-byebug' to my spec file!

Ravenous answered 22/1, 2023 at 19:49 Comment(0)
M
-3

I believe the issue here is that you're debugging inside a block, so you cannot call next while you're inside of it.

Monzon answered 5/2, 2016 at 12:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.