My goal is to use Pry as the console for my Rails app, both locally and on my staging server. But I can't get it to work on Heroku.
I'm following these instructions to get Heroku to use Pry as the console for my Rails app. When I run heroku run console pry
, my console prints Running console pry attached to terminal... up, run.1
and then exits. When I run heroku console pry
it just says main
and then exits.
Any ideas on what I'm doing wrong?
Here's what I've done so far:
In my Gemfile I've added the lines:gem 'pry'
gem 'pry-rails'
I've created a file called pry which contains:#!/usr/bin/env ruby
require 'pry'
pry
I added the following to all the files in config/environments:silence_warnings do
begin
require 'pry'
IRB = Pry
rescue LoadError
end
end
run bundle install
git push staging master
I am the one who developed the method for Heroku and Pry but you brought up an interesting case that I didn't think about since I mostly deploy with Sinatra and EM and build my own helpers and such. Either way:
To use Pry with Heroku while having a Rails app you just need to add pry-rails and pry to your gemfile (as a normal Gem) and then bundle install
and then git [commit|push]
and run heroku run console
on Cedar stack. Step 3 of what you did where you adjusted config/environments does not and should not be done so please revert that change if you can. After you do that and remove the pry script from the root of your app (well you don't necessarily need to do the latter) Pry will load with your Rails properly.
I've just used the instructions at https://github.com/pry/pry/wiki/Setting-up-Rails-or-Heroku-to-use-Pry to set it up, pry file goes in the root of your project. Commit and push to Heroku - I'm using the Cedar stack.
Effect a console session to heroku run console pry
- I did find that I did then need to execute pry
to be dropped into a pry prompt but it then worked as I'd expect.
UPDATE: Just to be clear, I added pry to Gemfile and created the pry file as instructed. Is your problem that you are locking pry in your gemfile to dev/test - are you running your apps on Heroku in those environments? Hence why you're getting undefined methods?
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