When you deploy an app based on a Buildpack (such as a Ruby on Rails application, but also e.g. a NodeJS or Go application), you might be wondering how to run the tasks which one would normally manage using e.g. heroku run taskname.
In our case, we were deploying a Rails application, and wanted to enter the Rails console.
Just trying /ap/bin/bundle exec rails console did not work, because the Ruby version which is installed globally in the container was Ruby 2.7.0, while the app was running on Ruby 2.6.6.
It turns out that the tasks you are looking for live in the /cnb/process/ directory. (ācnbā stands for āCloud Native Buildpacksā).
In our case, /cnb/process/console would open up the Rails console.
It was impossible to find any information about this elsewhere and it was only by trial and error that we found out how it works. I hope that by writing this post some other people might be helped in the future if they are searching for the same thing .
Happy to find this thread, was tough to find the rails console via ssh.
Perhaps a beginner follow-up question:
Iāve started the rails console process via /cnb/process/console but it either breaks right away, after the first input or is so laggy that itās pretty much unusable.
Am I doing something wrong, or there just minimal support for it yet?
Oh I just replied to your other post. Sometimes Rails VMs crash with an out of memory error when they donāt have enough RAM and you run the console. That would end the session.
If you run fly status --all after this happens you might see a VM in a āfailedā state. You can run fly vm status <id> on that one and it should tell you why it exited.
Is your app using a buildpack or a Dockerfile? You can tell from the [build] section of your fly.toml.
If itās Rails 7, we generate a Dockerfile for it (buildpacks are for older Rails). Assuming thatās the case, you should be able to get Rails console by running:
-> fly ssh console
$ cd /app/
$ rails console
There may be a one liner for the SSH command, weāll look!
fly ssh console -C "/bin/bash" -a app-name
Connecting to top1.nearest.of.<app-name>.internal... complete
root@96186c8f:/# ls -la /cnb/process
ls: cannot access '/cnb/process': No such file or directory
root@96186c8f:/# /lnb/launcher rails console
bash: /lnb/launcher: No such file or directory
root@96186c8f:/# /cnb/launcher rails console
bash: /cnb/launcher: No such file or directory
I might be in a new architecture or something because Iāve never seen the cnb dir: