Skip to content

Instantly share code, notes, and snippets.

@Sharpie
Last active October 3, 2016 23:44
Show Gist options
  • Save Sharpie/7b9baf8fb14e65634c99 to your computer and use it in GitHub Desktop.
Save Sharpie/7b9baf8fb14e65634c99 to your computer and use it in GitHub Desktop.
PE Debugging with Pry

This gist contains configuration to make Pry behave a bit better under Puppet Server JRuby.

For debugging, the following might be helpful:

  • Install the pry-nav gem. This is an oldschool "debugger" plugin for Pry and one of the first produced. Newer options like pry-debugger orpry-byebug are much, much better but are tightly integrated with CRuby. The pry-nav plugin provides "next", "step" and "continue" and is as dumb as a bag of hammers, but much better than nothing.

Outstanding issues:

  • Readline completion is busted under Puppet Server for some unknown reason. It works fine when running Pry under a normal JRuby shell. My guess is that some clojure bit is intercepting the tab characters.
if RUBY_ENGINE == 'jruby'
# Re-set TERM because Puppet Server strips the TERM variable.
# This re-enables Pry syntax highlighting.
ENV['TERM'] = 'xterm'
require 'pry'
# Disable paging of output. Pry falls back to a "simple" pager when running
# under JRuby which really breaks up the debugging flow. The downside to
# this is that some operations may flood the console with output.
Pry.config.pager = false
# Prevent pry from attempting to read config from root's home directory if
# a uid switch happened.
Pry.config.should_load_rc = false
Pry.config.should_load_local_rc = false
else
# puppet agent and puppet master --no-daemonize
require 'pry'
Pry.config.should_load_rc = false
Pry.config.should_load_local_rc = false
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment