Can't (re)deploy Rails 7: LoadError: cannot load such file -- /rails/lib/tasks/fly.rake

Looks like that was just before the Cut over to Rails Dockerfile Generator on Sunday 29 Jan 2023.

The new dockerfiles don’t use lib/tasks/fly.rake so you can delete it. With apps v2, fly.toml has changed quite a bit, so replace yours with the following:

app = "my-secret-app-name"
primary_region = "fra"
console_command = "/rails/bin/rails console"

[build]

[deploy]
  release_command = "./bin/rails db:prepare"

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ["app"]

[[statics]]
  guest_path = "/rails/public"
  url_prefix = "/"

Take a look at auto_stop_machines and auto_start_machines. If you want your machine to run 24/7, change both of these to false. If you leave these values as they are, your machine(s) will be stopped when idle.

You were also running with a swapfile. That, too, has changed. If you still want a swapfile, run the following, but only after you have replaced your fly.toml:

rails generate dockerfile --swap=512M
1 Like