Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

TLDR. I have two questions, though... the first one got answered after I typed all this up.

  1. How can I access objects inside of another object. (SOMEONE GAVE ME AN ANSWER. Feel free to skip to #2)

  2. I've attached by pry error output and gem list below, as will as troubleshooting and steps to reproduce it on my machine. (It's functionality is intermittent)

More detail on how I got the answer to #1

I was using IRB instead of Pry, couldn't tell that the objects were inside of an array. So, it's an array, so I can iterate through it with all the enumerables.

I was also causing myself probems because I'd not included attr_reader on appropriate Child variables, so I coudln't get to them when I DID try iterating through the array (before I knew for sure that it was an array.)

2. Troubleshooting Pry

Pry works if it's the only gem installed. It's working right now, because I've removed both pry-state and pry-byebug.

If I install pry-state or pry-byebug, I get the errors copied below anytime I enter a pry session, either by calling pry from the command line, or running a ruby file and hitting binding.pry.

I'd like to have some sort of debugger inside of pry, be it pry-state OR pry-byebug (or both!)

Finally, in case it's relevant, I edited my .pryrc file to customize the prompt:

# pulled from, slightly customized
Pry.prompt = [
  proc { |obj, nest_level, pry| "[#{pry.input_array.size}] \e[0;32mpry> \e[0m"},

The Error Messages and Gem List

[command-query (josh_answers)]$ pry -r ./children.rb
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/Pry.rb:14: warning: already initialized constant Pry::DEFAULT_HOOKS
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry.rb:14: warning: previous definition of DEFAULT_HOOKS was here
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/Pry.rb:20: warning: already initialized constant Pry::DEFAULT_PRINT
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry.rb:20: warning: previous definition of DEFAULT_PRINT was here
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/Pry.rb:29: warning: already initialized constant Pry::SIMPLE_PRINT
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry.rb:29: warning: previous definition of SIMPLE_PRINT was here
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/Pry.rb:38: warning: already initialized constant Pry::CLIPPED_PRINT
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry.rb:38: warning: previous definition of CLIPPED_PRINT was here
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/Pry.rb:43: warning: already initialized constant Pry::DEFAULT_EXCEPTION_HANDLER
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry.rb:43: warning: previous definition of DEFAULT_EXCEPTION_HANDLER was here
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/Pry.rb:52: warning: already initialized constant Pry::DEFAULT_PROMPT_NAME
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry.rb:52: warning: previous definition of DEFAULT_PROMPT_NAME was here
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/Pry.rb:55: warning: already initialized constant Pry::DEFAULT_PROMPT
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry.rb:55: warning: previous definition of DEFAULT_PROMPT was here
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/Pry.rb:65: warning: already initialized constant Pry::DEFAULT_PROMPT_SAFE_OBJECTS
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry.rb:65: warning: previous definition of DEFAULT_PROMPT_SAFE_OBJECTS was here
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/Pry.rb:68: warning: already initialized constant Pry::SIMPLE_PROMPT
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry.rb:68: warning: previous definition of SIMPLE_PROMPT was here
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/Pry.rb:70: warning: already initialized constant Pry::NO_PROMPT
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry.rb:70: warning: previous definition of NO_PROMPT was here
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/Pry.rb:72: warning: already initialized constant Pry::SHELL_PROMPT
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry.rb:72: warning: previous definition of SHELL_PROMPT was here
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/Pry.rb:79: warning: already initialized constant Pry::NAV_PROMPT
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry.rb:79: warning: previous definition of NAV_PROMPT was here
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/Pry.rb:94: warning: already initialized constant Pry::DEFAULT_CONTROL_D_HANDLER
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry.rb:94: warning: previous definition of DEFAULT_CONTROL_D_HANDLER was here
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/Pry.rb:109: warning: already initialized constant Pry::DEFAULT_SYSTEM
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry.rb:109: warning: previous definition of DEFAULT_SYSTEM was here
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/Pry.rb:117: warning: already initialized constant Pry::INITIAL_PWD
/Users/joshthompson/.rvm/gems/ruby-2.3.0/gems/pry-0.10.4/lib/pry.rb:117: warning: previous definition of INITIAL_PWD was here
[1] pry>


$ gem list | grep pry

pry (0.10.4)
pry-doc (0.10.0)

full list of gems

[command-query (josh_answers)]$ gem list

*** LOCAL GEMS ***

actioncable (
actionmailer (
actionpack (
actionview (
activejob (
activemodel (
activerecord (
activesupport (
ansi (1.5.0)
arel (7.1.4)
ast (2.3.0)
autoprefixer-rails (6.5.3)
axlsx (2.0.1)
bcrypt (3.1.11)
bigdecimal (default: 1.2.8)
bootstrap-sass (3.3.6)
builder (3.2.2)
bundler (1.14.3, 1.13.7, 1.13.6)
bundler-unload (1.0.2)
byebug (9.0.6, 9.0.0)
coderay (1.1.1, 1.0.9)
coffee-rails (4.2.1)
coffee-script (2.4.1)
coffee-script-source (1.11.1)
concurrent-ruby (1.0.2)
debug_inspector (0.0.2)
did_you_mean (1.0.0)
erubis (2.7.0)
execjs (2.7.0)
executable-hooks (1.3.2)
fancy_irb (1.0.2)
ffi (1.9.14)
formatador (0.2.5)
gem-wrappers (1.2.7)
globalid (0.3.7)
guard (2.14.0, 2.13.0)
guard-compat (1.2.1)
guard-minitest (2.4.4)
htmlentities (4.3.4)
i18n (0.7.0)
io-console (default: 0.4.5)
jbuilder (2.6.1, 2.4.1)
jquery-rails (4.2.1, 4.1.1)
json (default: 1.8.3)
listen (3.0.8)
loofah (2.0.3)
lumberjack (1.0.10)
mail (2.6.4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.10.1, 5.9.1, 5.8.3, 5.2.1)
minitest-homework (0.0.1)
minitest-reporters (1.1.9)
multi_json (1.12.1)
nenv (0.3.0)
net-telnet (0.1.1)
nio4r (1.2.1)
nokogiri (
notiffany (0.1.1)
paint (1.0.1)
parser (
pg (0.18.4)
power_assert (0.2.6)
powerpack (0.1.1)
pry (0.10.4)
pry-doc (0.10.0)
psych (default: 2.0.17)
puma (3.6.2, 3.4.0)
rack (2.0.1)
rack-test (0.6.3)
rails (
rails-controller-testing (0.1.1)
rails-dom-testing (2.0.1)
rails-html-sanitizer (1.0.3)
railties (
rainbow (2.2.1)
rake (11.3.0, 10.4.2)
rb-fsevent (0.9.8)
rb-inotify (0.9.7)
rdoc (default: 4.2.1)
rubocop (0.47.1)
ruby-progressbar (1.8.1)
rubygems-bundler (1.4.4)
rubygems-update (2.6.10, 2.6.8)
rubyzip (1.0.0)
rvm (
sass (3.4.22)
sass-rails (5.0.6)
shellany (0.0.1)
slop (3.6.0)
spring (2.0.0, 1.7.2)
spring-watcher-listen (2.0.1, 2.0.0)
sprockets (3.7.0)
sprockets-rails (3.2.0)
sqlite3 (1.3.12, 1.3.11)
test-unit (3.1.5)
thor (0.19.4)
thread_safe (0.3.5)
tilt (2.0.5)
turbolinks (5.0.1, 5.0.0)
turbolinks-source (5.0.0)
tzinfo (1.2.2)
uglifier (3.0.3, 3.0.0)
unicode-display_width (1.1.1)
web-console (3.4.0, 3.1.1)
websocket-driver (0.6.4)
websocket-extensions (0.1.2)
wirble (0.1.3)
yard (0.9.8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment