Pry gem gets hit, but then I can't type anything in console
Asked Answered
H

2

6

Its weird, I'm not getting any error messages, I just can't use Pry. The binding.pry gets hit, and processes stop. But then I can't actually use Pry I try and type, but it either doesn't work, or its gibberish and not the key's I'm hitting.

Any ideas on how to get Pry working? I'm running Ubuntu 14.04.3 LTS and the list of installed gems is:

source 'https://rubygems.org'

gem 'rails', '~>4.2.6'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'shopify_app', '~> 7.2'
gem 'shopify_api'
gem 'puma'
gem 'nokogiri'
gem 'httparty'
gem 'redis'
gem 'redis-namespace'
gem 'redis-rails'
gem 'redis-rack-cache'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'pry'

group :development do
  gem 'spring'
end

And then all the version numbers are as follows:

GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.7.1)
  actionpack (= 4.2.7.1)
  actionview (= 4.2.7.1)
  activejob (= 4.2.7.1)
  mail (~> 2.5, >= 2.5.4)
  rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.7.1)
  actionview (= 4.2.7.1)
  activesupport (= 4.2.7.1)
  rack (~> 1.6)
  rack-test (~> 0.6.2)
  rails-dom-testing (~> 1.0, >= 1.0.5)
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.7.1)
  activesupport (= 4.2.7.1)
  builder (~> 3.1)
  erubis (~> 2.7.0)
  rails-dom-testing (~> 1.0, >= 1.0.5)
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.7.1)
  activesupport (= 4.2.7.1)
  globalid (>= 0.3.0)
activemodel (4.2.7.1)
  activesupport (= 4.2.7.1)
  builder (~> 3.1)
activerecord (4.2.7.1)
  activemodel (= 4.2.7.1)
  activesupport (= 4.2.7.1)
  arel (~> 6.0)
activeresource (4.1.0)
  activemodel (~> 4.0)
  activesupport (~> 4.0)
  rails-observers (~> 0.1.2)
activesupport (4.2.7.1)
  i18n (~> 0.7)
  json (~> 1.7, >= 1.7.7)
  minitest (~> 5.1)
  thread_safe (~> 0.3, >= 0.3.4)
  tzinfo (~> 1.1)
arel (6.0.4)
builder (3.2.3)
coderay (1.1.1)
concurrent-ruby (1.0.4)
erubis (2.7.0)
execjs (2.7.0)
faraday (0.9.2)
  multipart-post (>= 1.2, < 3)
globalid (0.3.7)
  activesupport (>= 4.1.0)
hashie (3.5.1)
httparty (0.14.0)
  multi_xml (>= 0.5.2)
i18n (0.8.0)
jbuilder (2.6.1)
  activesupport (>= 3.0.0, < 5.1)
  multi_json (~> 1.2)
jquery-rails (4.2.2)
  rails-dom-testing (>= 1, < 3)
  railties (>= 4.2.0)
  thor (>= 0.14, < 2.0)
json (1.8.6)
jwt (1.5.1)
loofah (2.0.3)
  nokogiri (>= 1.5.9)
mail (2.6.4)
  mime-types (>= 1.16, < 4)
method_source (0.8.2)
mime-types (3.1)
  mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.10.1)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nokogiri (1.7.0.1)
  mini_portile2 (~> 2.1.0)
oauth2 (1.1.0)
  faraday (>= 0.8, < 0.10)
  jwt (~> 1.0, < 1.5.2)
  multi_json (~> 1.3)
  multi_xml (~> 0.5)
  rack (>= 1.2, < 3)
omniauth (1.4.1)
  hashie (>= 1.2, < 4)
  rack (>= 1.0, < 3)
omniauth-oauth2 (1.4.0)
  oauth2 (~> 1.0)
  omniauth (~> 1.2)
omniauth-shopify-oauth2 (1.1.17)
  oauth2 (~> 1.1.0)
  omniauth-oauth2 (~> 1.2)
pry (0.10.4)
  coderay (~> 1.1.0)
  method_source (~> 0.8.1)
  slop (~> 3.4)
puma (3.7.0)
rack (1.6.5)
rack-cache (1.6.1)
  rack (>= 0.4)
rack-test (0.6.3)
  rack (>= 1.0)
rails (4.2.7.1)
  actionmailer (= 4.2.7.1)
  actionpack (= 4.2.7.1)
  actionview (= 4.2.7.1)
  activejob (= 4.2.7.1)
  activemodel (= 4.2.7.1)
  activerecord (= 4.2.7.1)
  activesupport (= 4.2.7.1)
  bundler (>= 1.3.0, < 2.0)
  railties (= 4.2.7.1)
  sprockets-rails
rails-deprecated_sanitizer (1.0.3)
  activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.8)
  activesupport (>= 4.2.0.beta, < 5.0)
  nokogiri (~> 1.6)
  rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
  loofah (~> 2.0)
rails-observers (0.1.2)
  activemodel (~> 4.0)
railties (4.2.7.1)
  actionpack (= 4.2.7.1)
  activesupport (= 4.2.7.1)
  rake (>= 0.8.7)
  thor (>= 0.18.1, < 2.0)
rake (12.0.0)
redis (3.3.3)
redis-actionpack (5.0.1)
  actionpack (>= 4.0, < 6)
  redis-rack (>= 1, < 3)
  redis-store (>= 1.1.0, < 1.4.0)
redis-activesupport (5.0.1)
  activesupport (>= 3, < 6)
  redis-store (~> 1.2.0)
redis-namespace (1.5.2)
  redis (~> 3.0, >= 3.0.4)
redis-rack (1.6.0)
  rack (~> 1.5)
  redis-store (~> 1.2.0)
redis-rack-cache (2.0.0)
  rack-cache (~> 1.6.0)
  redis-store (~> 1.2.0.pre)
redis-rails (5.0.1)
  redis-actionpack (~> 5.0.0)
  redis-activesupport (~> 5.0.0)
  redis-store (~> 1.2.0)
redis-store (1.2.0)
  redis (>= 2.2)
sass (3.4.23)
sass-rails (5.0.6)
  railties (>= 4.0.0, < 6)
  sass (~> 3.1)
  sprockets (>= 2.8, < 4.0)
  sprockets-rails (>= 2.0, < 4.0)
  tilt (>= 1.1, < 3)
shopify_api (4.3.5)
  activeresource (>= 3.0.0)
  rack
shopify_app (7.2.3)
  omniauth-shopify-oauth2 (~> 1.1.11)
  rails (>= 4.2.6)
  shopify_api (>= 4.2.2)
slop (3.6.0)
spring (2.0.1)
  activesupport (>= 4.2)
sprockets (3.7.1)
  concurrent-ruby (~> 1.0)
  rack (> 1, < 3)
sprockets-rails (3.2.0)
  actionpack (>= 4.0)
  activesupport (>= 4.0)
  sprockets (>= 3.0.0)
sqlite3 (1.3.13)
thor (0.19.4)
thread_safe (0.3.5)
tilt (2.0.6)
turbolinks (5.0.1)
  turbolinks-source (~> 5)
turbolinks-source (5.0.0)
tzinfo (1.2.2)
  thread_safe (~> 0.1)
uglifier (3.0.4)
  execjs (>= 0.3.0, < 3)

PLATFORMS
  ruby

DEPENDENCIES
  httparty
  jbuilder (~> 2.0)
  jquery-rails
  nokogiri
  pry
  puma
  rails (~> 4.2.6)
  redis
  redis-namespace
  redis-rack-cache
  redis-rails
  sass-rails (~> 5.0)
  shopify_api
  shopify_app (~> 7.2)
  spring
  sqlite3
  turbolinks
  uglifier (>= 1.3.0)

  BUNDLED WITH
   1.13.6
Himelman answered 9/2, 2017 at 14:54 Comment(3)
try adding pry-rails to your Gemfile and bundle installing. it helps with proper integration of rails and pry.Augite
yea not working, my gems are a mess somehow.. multiple versions of the same gem etc..Himelman
try byebug instead, it can be a little less buggy sometimes but it doesn't have as many features.Taggart
L
19
  • This can happen if you're running your application usingforeman. This is just how foreman handles processes.
  • Once you have hit the breakpoint, type whatever you need to as fast as you can before foreman takes over.
  • Unfortunately, you won't be able to see what you are typing but for as long as you type in the correct thing, you should be able to see the outputs.

    1. Alternatively, if this is my foreman command foreman start -f Procfile.dev

    2. Go to the file that foreman is running (mine is Procfile.dev), and remove the line that runs your rails server, for me, it is something like web: rails s -b 0.0.0.0 Now run rails s -b 0.0.0.0 separately in a different terminal session.

    3. You should now see anything you type after your breakpoint and can debug however you like. Beware, if you take too long foreman will take over and you will not be able to type. In case it does, restart the rails server.
Labyrinthodont answered 23/3, 2018 at 9:48 Comment(1)
Good to know others do the same thing! Kind of annoying that there's no real workaround.Bedrock
T
1

Just ran into this years later --

The solution I ended up going with was switching from foreman to overmind. It uses the same type of Procfile format as foreman, so you probably wouldn't have to make changes there. Basically just follow this article here, but to summarize:

  • Install tmux and overmind
  • Place your pry/debugger as normal
  • In a separate shell, run overmind connect [name of rails server in your Procfile, probably 'web'] and it'll let you connect to your process and respond to the debug prompt

The only downside(?) is if you're unfamiliar with tmux and doing anything more than directly connecting to one process at a time, there's a bit to learn about navigation.

Alternatively... if you only need to run two or three processes to support your app, you could just start them manually instead of using foreman or overmind. Running rails server directly circumvents this problem. You could also use foreman to start all processes except your Rails server, and run it manually (as suggested in the accepted answer).

Twitch answered 22/7, 2023 at 23:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.