How to get into the Rails console, or other tasks in a buildpack-based deploy

I’m using pretty standard buildpacks:

  builder = "heroku/buildpacks:20"
  buildpacks = ["heroku/nodejs", "heroku/ruby"]

So I was able to get this working by:

fly ssh console
cd /app
cat profile.d/ # executing is denied

Exporting the variables found there manually sets up what we need. Then we can do bin/rails c and the console loads.

Update: My solution no longer works as now /app/profile.d no longer exists. For a few minutes on one deploy (currently working through another issue) /cnb/process existed but then disappeared when deploying again.

1 Like

I was able to get it working by doing:

fly ssh console
cd /app
bin/rails c

Hope this helps someone.


Once I cleared up (admittedly many) other issues this seemed to go away, so I don’t have the solution as everything I did wasn’t related to this issue.

This was the most succinct way of getting into rails console that I have found so far:

fly ssh console -C "/app/bin/rails console"
1 Like

How do you install the apt buildpack ?

This issue is cropping up again for me. The furthest I can get is:

  1. fly ssh console
  2. bash
  3. cd /app
  4. bin/rails c

Then I get an error about Ruby versions:

Your Ruby version is 2.7.0, but your Gemfile specified 3.2.2

I’ve got no idea where Ruby 2.7.0 comes from, .ruby-version is 3.2.2 — I haven’t used Ruby 2 in probably years now.

Does your Dockerfile have a line that looks like:


If you have not been making changes to your Dockerfile, you can regenerate it using:

bin/rails generate dockerfile

If you run this command, you will get the ability to review the changes before accepting them. If you need to install the generator, you can follow these instructions.

Hello @rubys, I’m using a buildpack so I don’t have a Dockerfile.

In that case, the 2.7.0 is likely coming from the buildpack. I’d encourage you to try a Dockerfile using the instructions from the link above.