"No Rakefile found" upon running example command

I am trying to run basic commands from this page, starting with the first one:

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

But this command returns an error on a perfectly well deployed app:

rails aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)

In fact, a few commands run successfully that way: rails routes, rails help, rails version but not rails db:migrate or rails db:seed for instance.

Any idea why they don’t work and how I can make them work from CLI without entering console? (for CD purposes)

Try adding the following to your Dockerfile, after the COPY . . line:

RUN sed -i '/^#!/aDir.chdir File.expand_path("..", __dir__)' /app/bin/*

The reason why these commands don’t work is that a number of Rails commands issue Rake commands on your behalf, and Rake looks for a Rakefile in your current working directory.

We are continuing to look for other fixes to this problem, but for now adjusting your binstubs gets you around this problem. The change above will make the next release of flyctl so projects
that issue fly launch once that is released will have this fix.

Thank you @rubys, works like a charm!

In the past 2 weeks, I noticed you put effort to improve the Rails experience, so I understand a lot is still work in progress. I’ll make sure to run fly launch on a regular basis to see how the defaults change.

That’s nice to hear. In case you are interested, you can find my backstory here. Don’t be shy - questions, feedback, and suggestions will help me make fly.io better for everyone.

Happy retirement!

Oh wow! The actual Sam Ruby is on the team !?!
We’re in safe hands. I feel a lot more confident in the fly.io product now.

1 Like