4
votes

My workstation:

$ uname -a
Linux dsktop 3.13.0-77-generic #121-Ubuntu SMP Wed Jan 20 10:50:42 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux-gnu]
# (also same behavior with ruby 2.3.1)

I've researched this, found pry-nav work unexpectedly -- but reinstalls per that question have not fixed my problem.

Problem -- I've recently installed Ruby 2.2 and 2.3 system-wide using Brightbox Cloud ppa resources, e.g.:

$ sudo apt-add-repository ppa:brightbox/ruby-ng
$ sudo apt-get update
$ sudo apt-get install ruby2.3 ruby2.3-dev

And then installed the Pry gem and relevant dependencies:

$ sudo gem install pry pry-nav pry-byebug

Resulting in this:

$ sudo gem list pry

*** LOCAL GEMS ***

pry (0.10.3)
pry-byebug (3.3.0)
pry-nav (0.2.4)

It's also necessary to open up file-access a bit:

$ sudo chmod -R 755 /var/lib/gems
$ sudo chmod    755 /usr/local/bin/pry
$ sudo chmod    755 /usr/local/bin/byebug

I'd previously had Pry working on an older RVM rig with Ruby 1.9 and 2.1, and things worked great there, but I've apparently "lost the formula" for Pry installation, or something's subtly changed (?). Oh, and no Rails to complicate things, just simple Ruby scripts.

When I run script code that looks like this (and which worked fine with the RVM rig and private-installed gems):

require 'pry'
binding.pry

args = ARGV.join( ' ' )
# Check that only numbers 0..9, arithmetical operators +, -, * and /,
# decimal, comma, space and parentheses () are present in args:

Expecting, of course, that Pry-Byebug will breakpoint at the line following the binding.pry method call. Instead, the following breakpoint (?) is displayed:

From: /var/lib/gems/2.2.0/gems/pry-nav-0.2.4/lib/pry-nav/tracer.rb @ line 21 PryNav::Tracer#run:

    12: def run(&block)
    13:   # For performance, disable any tracers while in the console.
    14:   # Unfortunately doesn't work in 1.9.2 because of
    15:   # http://redmine.ruby-lang.org/issues/3921. Works fine in 1.8.7 and 1.9.3.
    16:   stop unless RUBY_VERSION == '1.9.2'
    17: 
    18:   return_value = nil
    19:   command = catch(:breakout_nav) do      # Coordinates with PryNav::Commands
    20:     return_value = yield
 => 21:     {}    # Nothing thrown == no navigational command
    22:   end
    23: 
    24:   # Adjust tracer based on command
    25:   if process_command(command)
    26:     start
    27:   else
    28:     stop if RUBY_VERSION == '1.9.2'
    29:     if @pry_start_options[:pry_remote] && PryNav.current_remote_server
    30:       PryNav.current_remote_server.teardown
    31:     end
    32:   end
    33: 
    34:   return_value
    35: end

pry> 

So, what's happening here? Why does Pry break at line 21 in the run module of .../pry-nav/tracer.rb?

How must Pry and Byebug be installed to result in a working set of Gems?

I promise to document this answer carefully so I'll not loose it again in the future! TIA.

ADDED -- After posting this question, I did more digging and came across this:

https://plus.google.com/114275173749981855325/posts

which suggested that only pry and pry-nav should be installed, but not pry-byebug. So, I uninstalled pry-byebug, and ta-da! Pry debugging started working properly again.

I apologize for asking such a lengthy question, only to answer it myself with such a simple solution. Hopefully, y'all will let this post persist as an improvement to "how to install Pry" for the future. Existing "authoritative" documentation on pry installation is ambiguous and inaccurate (or maybe just doesn't address this potential problem).

Thank you, and again, sorry for the trouble and confusion.

1
You can add your answer and accept it but perhaps summarize as there seems to be a lot of not so useful text included.osman
The post @Lorin is referencing to is thecuriousrubyprogrammer.blogspot.com/2015/08/…Dorian
Possible duplicate of pry-nav work unexpectedlyDorian

1 Answers

3
votes

Uninstalling pry-nav seems to make it work fine again :)

gem uninstall pry-nav