Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pry not starting after installing pry-rails #97

Open
thestrabusiness opened this issue Jun 21, 2017 · 12 comments
Open

Pry not starting after installing pry-rails #97

thestrabusiness opened this issue Jun 21, 2017 · 12 comments

Comments

@thestrabusiness
Copy link

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 run bundle 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:

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

ruby '2.4.1'

gem 'aws-sdk'
gem 'bootstrap-sass'
gem 'celluloid-io'
gem 'dotenv-rails'
gem 'inline_svg'
gem 'jbuilder', '~> 2.5'
gem 'jquery-rails'
gem 'metainspector'
gem 'monban'
gem 'newrelic_rpm'
gem 'otr-activerecord'
gem 'paperclip'
gem 'pg'
gem 'puma', '~> 3.0'
gem 'pundit'
gem 'rails', '~> 5.0.2'
gem 'sass-rails', '~> 5.0'
gem 'slack-ruby-bot-server'
gem 'turbolinks', '~> 5'
gem 'uglifier', '>= 1.3.0'

group :development do
  gem 'better_errors'
  gem 'listen', '~> 3.0.5'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'web-console', '>= 3.3.0'
end

group :development, :test do
  gem 'pry-rails'
  gem 'binding_of_caller'
  gem 'railroady'
end

group :test do
  gem 'capybara-webkit'
  gem 'database_cleaner'
  gem 'factory_girl_rails'
  gem 'rspec-rails'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Gemfile.lock shows pry and pry-rails:

pry (0.10.4)
pry-rails (0.3.6)
  pry (>= 0.10.4)
@mswieboda
Copy link

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.

@anaumov
Copy link

anaumov commented Aug 25, 2017

Same problem here with rails 5. Even can't require 'pry' in console

UPD: it just works now. May be new rails works well.

@thromera
Copy link

Same issue with Rails 5.1.2, ruby 2.4.1p111 :(.

@alexdilley
Copy link

Find it works if you DISABLE_SPRING:

$ DISABLE_SPRING=1 bin/rails c
Loading development environment (Rails 5.1.4)
[1] pry(main)>

🙄

@0x1eef
Copy link
Contributor

0x1eef commented Nov 12, 2017

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.

@dennyluan
Copy link

Unfortunately, the disable_spring option doesn't work for me in rails 5.0.6.

@0x1eef
Copy link
Contributor

0x1eef commented Dec 23, 2017

@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.

@karuppasamy
Copy link

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)>

@PrimeTimeTran
Copy link

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!

screen shot 2018-01-02 at 2 38 20 am

@mswieboda
Copy link

@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.

@argent-codes
Copy link

argent-codes commented Feb 19, 2021

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.

@technicalpickles
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests