I'm confused about which gems need to be installed to correctly run Pry in a Rails 4.2 project. I seemed to be doing fine until recently. For some reason, binding.pry
now seems to spit up whenever I try to step through a console session with next
, step
, etc in the command line. It will throw an ugly stack trace, then show me the same point in the code, without stepping further. After the second next
command, it throws the same stack trace and quits, returning execution to the localhost server. I get a runtime error on the browser page with No frames collected
.
If I comment out the binding.pry
in my code, everything works fine. So I strongly suspect something is wrong with my configuration of Pry. It seems like there are several dozen variations of Pry, with no clear guidance on which one(s) should be installed, which might conflict, etc.
Here's the stack trace I get when calling next
in the Pry console after the code reaches the binding.pry
call:
From: /Users/me/sites/arailsapp/app/controllers/bars_controller.rb @ line 31 BarsController#edit:
29: def edit
30: binding.pry
=> 31: @bar = Bar.find(params[:id])
32: @foo = @bar.foo
33: end
[6] pry(#<BarsController>)> n
Completed 500 Internal Server Error in 2685ms (ActiveRecord: 0.0ms)
RuntimeError - No frames collected.:
pry-byebug (3.2.0) lib/byebug/processors/pry_processor.rb:122:in `perform_next'
pry-byebug (3.2.0) lib/byebug/processors/pry_processor.rb:60:in `perform'
pry-byebug (3.2.0) lib/byebug/processors/pry_processor.rb:49:in `run'
pry-byebug (3.2.0) lib/byebug/processors/pry_processor.rb:111:in `resume_pry'
pry-byebug (3.2.0) lib/byebug/processors/pry_processor.rb:69:in `at_line'
byebug (5.0.0) lib/byebug/context.rb:90:in `at_line'
app/controllers/scholarships_controller.rb:31:in `edit'
actionpack (4.2.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.2.1) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.1) lib/active_support/callbacks.rb:117:in `call'
# omitting the next ~40 lines in the Rails stack...
Second verse looks same as the first - at which point execution returns to the server.
Here is my Gemfile:
source 'https://rubygems.org'
ruby '2.2.0'
gem 'rails', '4.2.1'
gem 'pg', '~> 0.18.2'
gem 'haml-rails', '~> 0.9.0'
gem 'sass-rails', '~> 5.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'will_paginate', '~> 3.0.7'
gem 'will_paginate-bootstrap'
gem "nilify_blanks"
gem 'filterrific', '~> 2.0.5'
gem 'chardinjs-rails'
# Install bootstrap and associated gems
gem 'bootstrap-sass', '~> 3.3.4.1'
gem 'autoprefixer-rails', '~> 5.2.0'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
group :production do
gem 'rails_12factor', '~> 0.0.3'
end
group :assets do
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
end
group :development do
gem 'better_errors', '~> 2.1.1'
gem 'annotate', '~> 2.6.10'
end
group :development, :test do
gem 'pry-rails'
gem 'pry-stack_explorer'
gem 'pry-byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'spring-commands-rspec', '~> 1.0.4'
gem 'rspec-rails', '~> 3.2.3'
gem 'guard-rspec', '~> 4.6.0'
gem 'sqlite3'
gem 'factory_girl_rails', '~> 4.5.0', require: false
end
group :test do
gem 'database_cleaner', '~> 1.4.1'
gem 'faker', '~> 1.4.3'
gem 'capybara', '~> 2.4.4'
gem 'launchy', '~> 2.4.3'
gem 'shoulda', '~> 3.5.0'
end
I've also tried with the pry-stack_explorer
and pry-byebug
gems commented out...no difference.
And finally, my .pryrc file:
# ~/.pryrc
if defined?(PryByebug)
Pry.commands.alias_command 'c', 'continue'
Pry.commands.alias_command 's', 'step'
Pry.commands.alias_command 'n', 'next'
Pry.commands.alias_command 'f', 'finish'
end
# Hit Enter to repeat last command
Pry::Commands.command /^$/, "repeat last command" do
_pry_.run_command Pry.history.to_a.last
end
Some fiddling around and a couple of server restarts appear to have fixed the issue. Thanks to Deivid for suggesting remvoving pry-stack_explorer
. Here's the Gemfile for the test and development groups:
group :development do
gem 'better_errors', '~> 2.1.1'
gem 'annotate', '~> 2.6.10'
end
group :development, :test do
gem 'pry-rails'
gem 'pry-byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'spring-commands-rspec', '~> 1.0.4'
gem 'rspec-rails', '~> 3.2.3'
gem 'guard-rspec', '~> 4.6.0'
gem 'sqlite3'
gem 'factory_girl_rails', '~> 4.5.0', require: false
end
group :test do
gem 'database_cleaner', '~> 1.4.1'
gem 'faker', '~> 1.4.3'
gem 'capybara', '~> 2.4.4'
gem 'launchy', '~> 2.4.3'
gem 'shoulda', '~> 3.5.0'
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With