fork/exec rails/bin/rails: no such file or directory

I have noticed in two different Apps, that after running a fly deploy I can’t perform flyctl ssh console -C "rails/bin/rails db:migrate" any more.

It was working previously for both Apps, after deploying is retrieving this error:

fork/exec rails/bin/rails: no such file or directory

Do you know what could be the problem?

Thank you very much!

Over the past few months, the Dockerfile generated for Rails apps has changed considerably, so answering this properly won’t be possible without what your Dockerfile looks like. As an example, rails applications are now placed in /rails whereas they previously were placed in /app.

If you run the following command, what do you get?

flyctl ssh console -C 'sh -c (pwd;ls)'

Hi @rubys , thanks for your reply! :pray:. I get this:

app bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv swapfile sys tmp usr var

Indeed, if I run the command like this it works for this App:

fly deploy I can’t perform flyctl ssh console -C "rails/bin/rails db:migrate"

For the other app, which doesn’t work with any of those options, I get this when running the command you suggested :

bin boot dev etc home lib lib64 media mnt opt proc rails root run sbin srv sys tmp usr var

So you have two apps, with two different working directories. For one you will need to do:

flyctl ssh console -C "app/bin/rails db:migrate"

If you like, you can update your Dockerfile to what fly will currently produce (and to closely match what Rails will be including in Rails 7.1) with the following commands:

bundle add dockerfile-rails --optimistic --group development
bin/rails generate dockerfile

Thank you @rubys, I tried those commands and re-deployed the second App. It seems like I don’t have the /app directory yet, and continue to have the error:

fork/exec app/bin/rails: no such file or directory

Also, this is what I get when running the ls in fly.io console:

bin boot dev etc home lib lib64 media mnt opt proc rails root run sbin srv sys tmp usr var

Thanks again, really appreciate the help!

Sorry, I was unclear. Older Dockerfiles created an app directory. Newer Dockerfile create a rails directory. If you see rails in the output:

bin boot dev etc home lib lib64 media mnt opt proc rails root run sbin srv sys tmp usr var
                                                                                         ^^^

Then the command to issue is:

fly deploy I can’t perform flyctl ssh console -C "rails/bin/rails db:migrate"

Anticipating what your next error might be, the following command may also be necessary:

bin/rails generate dockerfile --bin-cd

See: Dockerfiles and fly.toml · Fly Docs for more details

That helped, thank you very much @rubys !! :pray: :pray:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.