44

In byebug we can move to next line by typing 'n', similarly is there anyway to move to the next line in 'pry' ?

I have gone through there documentation but nothing's works out.

3 Answers 3

33

Check out pry-nav, it gives you methods like next and step, which should be what you're looking for.

If you're in regular old Pry you can use exit to go to the next binding.pry or disable-pry to exit Pry entirely.

Sign up to request clarification or add additional context in comments.

3 Comments

There's also pry-byebug to combine these two libraries.
@user9015957 What do you mean, "it doesn't work"? You need to be a bit more specific about exactly what you have tried and what errors you are seeing. I suggest you create a new question with a more complete description of the problem, if you are still having difficulty.
It seems like pry-nav and pry-rails currently require different versions of pry and are incompatible.
22

You can't. pry doesn't have any command who let you jump to the next line. So, your alternatives are:

  1. Adding a new pry.binding on the next breakpoint and then using exit to jump between bingings.
  2. Using a gem like pry-byebug or pry-nav who adds the next command to jump to the next line.
  3. Using a gem like pry-byebug or pry-debugger who adds the break command to add breakpoints like break <Class#method>.

Installing pry-byebug is the best solution for your case, you can't achieve this with just pry.

Comments

5

you can exit to continue the code flow

5 Comments

Why was this answer down voted? Please leave comments when down voting answers. This is the correct answer without using any additional libraries.
Because he is asking how to go to next line not how to exit the breaking point, just like 'next' || 'n' in byebug
He is asking how to go to the next line in binding.pry. When you use binding.pry, the flow of the execution stops on that line and to resume the flow you use exit. If you want to stop at the next line, you can place another binding.pry there but that would be kind of pointless
instead of placing multiple pry you can use gem 'pry-byebug' to take advantage of both gems
You are right but I was trying to answer him without any additional gems. Why would anyone place multiple binding.pry :p

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.