Open thestrabusiness opened 7 years ago
I'm having a similar issue, Rails 5.1.2 ruby 2.3.4, fresh installs today.
I can't even do require 'pry'
from rails console
once it loads IRB. Which is why I imagine it's failing:
irb(main):001:0> require 'pry'
LoadError: cannot load such file -- pry
from (irb):1
Maybe it's something with Rails 5? I'm more familiar with Rails 4, which I've had no pry
problems, and have loaded pry
using `~/.irbrc via https://github.com/pry/pry/wiki/Setting-up-Rails-or-Heroku-to-use-Pry#with-irbrc-file.
Same problem here with rails 5. Even can't require 'pry'
in console
UPD: it just works now. May be new rails works well.
Same issue with Rails 5.1.2
, ruby 2.4.1p111
:(.
Find it works if you DISABLE_SPRING
:
$ DISABLE_SPRING=1 bin/rails c
Loading development environment (Rails 5.1.4)
[1] pry(main)>
🙄
This comment won't help.. but check out some of the alternative web frameworks so Ruby on Rails doesn't have such an iron grip influence on the available options in the professional Ruby space. I feel sorry for people caught up in DHH-ism and I think a backlash is inevitable, because there is never one 'One Right Way' and having an opinionated framework is fine, if other opinions can breath and excel as well. My two cents.
Unfortunately, the disable_spring
option doesn't work for me in rails 5.0.6.
@rf- can you look into this if you have time? or @kyrylo neither banister nor myself use rails and i don't have the motivation to look into it. otherwise a third party contributor will have to step up to solve the issue.
I don't see any issues.
demoapp$ rails -v
Rails 5.1.4
demoapp$ ruby -v
ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-darwin17]
demoapp$ rails c
Running via Spring preloader in process 82783
Loading development environment (Rails 5.1.4)
[1] pry(main)>
A little bit off topic but do you guys ever have problems with pry working on Ajax
requests?
Pry doesn't stop on Ajax requests and simply prints to the screen and then the request continues. Sorry if this is a newb question!
@PrimeTimeTran use Chrome debugger for AJAX, pry Rails. If you need pry for AJAX, then you can try pry-remote
that might help, I've used that in the past for asynchronous requests, like redis, sidekiq, etc.
EDIT: Turns out I was using an older version of this gem, 0.3.6. Upgrading to 0.3.9 fixed the issue for me (though the warnings on the bottom are still there).
It looks like this project hasn't been updated in some time, but I ran into this (or a similar) issue after going to Rails 6, and was seemingly able to fix it by updating my application.rb
with something similar to what this gem does:
class Application < Rails::Application
config.console = Pry
# the rest of my config here...
end
Or, more accurately, I updated my config/environments/development.rb
with
require 'pry'
Rails.application.configure do
config.console = Pry
# ...
end
I am getting some warnings when fire up the console:
<main>: warning: __FILE__ in eval may not return location in binding; use Binding#source_location instead
/Users/ekirilov/.gem/ruby/2.7.2/gems/pry-byebug-3.6.0/lib/pry-byebug/base.rb:9: warning: in `eval'
/Users/ekirilov/.gem/ruby/2.7.2/gems/pry-byebug-3.6.0/lib/pry-byebug/pry_ext.rb:11: warning: __FILE__ in eval may not return location in binding; use Binding#source_location instead
/Users/ekirilov/.gem/ruby/2.7.2/gems/pry-stack_explorer-0.4.9.2/lib/pry-stack_explorer/when_started_hook.rb:63: warning: in `eval'
/Users/ekirilov/.gem/ruby/2.7.2/gems/railties-6.0.3.5/lib/rails/commands/console/console_command.rb:70: warning: __FILE__ in eval may not return location in binding; use Binding#source_location instead
/Users/ekirilov/.gem/ruby/2.7.2/gems/pry-stack_explorer-0.4.9.2/lib/pry-stack_explorer/when_started_hook.rb:63: warning: in `eval'
Frame number: 0/9
<main>: warning: __FILE__ in eval may not return location in binding; use Binding#source_location instead
/Users/ekirilov/.gem/ruby/2.7.2/gems/pry-0.11.3/lib/pry/commands/whereami.rb:41: warning: in `eval'
<main>: warning: __LINE__ in eval may not return location in binding; use Binding#source_location instead
/Users/ekirilov/.gem/ruby/2.7.2/gems/pry-0.11.3/lib/pry/commands/whereami.rb:42: warning: in `eval'
So it's possible that I'll still run into issues down the line, but this at least allows me use the pry
console helpers I have defined in my .pryrc
.
I suspect some of the problems reported here have to do with spring
. More recent versions of spring should be handling restarting when things like the Gemfile change, so I don't expect it to be a problem anymore.
I'm trying to include
pry-rails
in a Rails 5 app using Ruby 2.4.1, but it doesn't seem to replace irb in the console.I've included
pry-rails
in my gemfile and runbundle install
, but when I start the console it still uses irb. I tried moving it out of the development group, but that made no change. Am I missing a step here? Thanks in advance.Gemfile:
Gemfile.lock shows pry and pry-rails: