Open rycwilson opened 8 years ago
Problem seems to be restricted to Active Record methods: User.all
, User.first
, User.where(...)
, etc
show-model User
output prints as expected
I'm also experiencing this issue and I'm not sure where to start looking for a solution. Did you happen to find a fix?
No solution, instead I switched to Jazz Hands: https://github.com/nixme/jazz_hands
Works great with a few caveats:
1 - I have noticed some issues with binding.pry (e.g. if I mistype a command when I'm in a bound pry shell, it goes into a weird state where everything I type comes up with random key mappings and I can't exit the shell, have to re-start the server).
2 - Also have seen line-wrapping issues when I'm using iTerm2 with multiple shells open
This is my setup:
gem 'jazz_hands', github: 'nixme/jazz_hands', branch: 'bring-your-own-debugger' gem 'pry-byebug'
On Tue, Oct 25, 2016 at 1:34 PM, Fred Sladkey notifications@github.com wrote:
I'm also experiencing this issue and I'm not sure where to start looking for a solution. Did you happen to find a fix?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rweng/pry-rails/issues/83#issuecomment-256167336, or mute the thread https://github.com/notifications/unsubscribe-auth/AJwvpPuiX82fUEUsXE-uSu1ZocxUN_xtks5q3mfDgaJpZM4JzRc9 .
Okay, thanks! Nice to have an alternative. I realized my issue may have something to do with using rails 5 but haven't tried to replicate it in earlier versions. If I find a solution or explanation I'll post here.
As luck would have it jazz_hands appears to be incompatible with Rails 5, as it requires Railties < 5, while Rails 5 requires Railties = 5.
Doesn't seem as though either pry-rails or jazz_hands are maintained any longer. Are there alternatives out there??
Try this for a fix:
gem 'pry-rails' gem 'awesome_print'
... and in your .pryrc, add this (ref):
begin
require 'awesome_print'
AwesomePrint.defaults = {
indent: -2, # left aligned
sort_keys: true, # sort hash keys
# more customization
}
Pry.config.print = proc { |output, value| Pry::Helpers::BaseHelpers.stagger_output("=> #{value.ai}", output) }
rescue LoadError => err
puts "no awesome_print :("
end
+1 User no longer pretty prints. Using devise as well.
Caused by Devise authenticable module having custom inspect method:
PP then tries its best to do something, but hasn't got line breaks or anything, as per https://github.com/ruby/ruby/blob/trunk/lib/pp.rb#L295-L321
Solution is to either use awesome_print as formatter OR define custom pretty_print method, check the docs here http://ruby-doc.org/stdlib-2.0.0/libdoc/pp/rdoc/PP.html
@rycwilson it works perfectly !
After using these two gems together successfully for the last year, suddenly the console won't pretty print either of my devise models. All other models print in the console as expected, but User and Admin print in the traditional rails/irb fashion.
Curiously this manifests in a dev branch but not in my master branch, so I suppose that gives me hope for tracking down the problem. Gemfiles are identical - both contain pry-rails 0.3.4 and pry 0.10.4. Precisely nothing was changed in user.rb or admin.rb prior to this problem appearing.
Any tips for debugging?