I can't seem to get a rails console

I’m trying to migrate from heroku to fly, and the last piece I’m missing is how to get a rails console. This could just be a lack of my cloud native knowledge or somehow related the buildpacks I’m using.

I try to get a console with:

flyctl ssh console -C '/app/bin/rails console'

But I get stuck with an error:

Your Ruby version is 2.7.0, but your Gemfile specified 3.1.1

I’ve also tried:

flyctl ssh console -C 'bash'
cd /app
bin/rails console

But still get the error:

Your Ruby version is 2.7.0, but your Gemfile specified 3.1.1

Here’s some of my toml:

kill_signal = "SIGINT"
kill_timeout = 5

[processes]
web = "bin/puma -C config/puma.rb"
worker = "bin/good_job"

[build]
  builder = "heroku/buildpacks:20"
  buildpacks = ["fagiani/apt@0.2.1", "heroku/ruby@0.1.3"]
  [build.args]
    DATABASE_URL="sqlite3:///tmp/db.sqlite3"
    RAILS_MASTER_KEY=""
    E_API_KEY=""
    S3_BUCKET_NAME=""
    S3_REGION=""    
    J_API_KEY=""
    API_KEY=""
    SENTRY_DSN=""
    OK_API_KEY=""
    STRIPE_ENV=""
    HOSTNAME=""

[deploy]
  release_command = "bin/rails db:migrate"

The rails web app and the worker process both run fine. The release command to migrate the db runs fine. I just don’t have a way in to inspect the app state.

:smile: I figured it out.

After another try I found out about the /cnb/process/console and when I tried to run it I got booted from the ssh connection. I looked at the logs and found out the VM was running out of memory and restarting. So I change the size of the app from 256MB to 512MB and then ran:

flyctl ssh console -C '/cnb/process/console'

And immediately got a rails console:

Connecting to top1.nearest.of.myapp.internal... complete
Loading production environment (Rails 7.0.2.2)
irb(main):001:0>
1 Like

Oh good catch! OOMs are hard because they don’t print anything.