Lucky app (Crystal) deploy fail

Hey,

I am trying to deploy a simple Lucky app (Crystal), however I am getting a strange exception. The error is from Crystal, the exception is triggered when the watch.yml file is missing. It looks like the aforementioned file is missing. Locally, the app is working absolutely fine. Here is the log. Much appreciated.

Recent Logs
2022-06-24T20:04:37.000 [info] Starting virtual machine
2022-06-24T20:04:37.000 [info] [    0.023912] PCI: Fatal: No config space access function found
2022-06-24T20:04:37.000 [info] Starting init (commit: e21acb3)...
2022-06-24T20:04:37.000 [info] Preparing to run: `./webserver` as root
2022-06-24T20:04:37.000 [info] 2022/06/24 20:04:37 listening on [fdaa:0:714b:a7b:b9b7:12ed:bced:2]:22 (DNS: [fdaa::3]:53)
2022-06-24T20:04:37.000 [info] Unhandled exception: Expected config file for the watcher at ./config/watch.yml (Exception)
2022-06-24T20:04:38.000 [info]   from /usr/share/crystal/src/file.cr:650:26 in 'settings'
2022-06-24T20:04:38.000 [info]   from /webserver_build/lib/lucky/src/lucky/server_settings.cr:9:5 in '__crystal_main'
2022-06-24T20:04:38.000 [info]   from /usr/share/crystal/src/crystal/main.cr:115:5 in 'main'
2022-06-24T20:04:38.000 [info]   from src/env/__libc_start_main.c:94:2 in 'libc_start_main_stage2'
2022-06-24T20:04:38.000 [info] Main child exited normally with code: 1
2022-06-24T20:04:38.000 [info] Starting clean up.
2022-06-24T20:04:44.000 [info] Starting instance
2022-06-24T20:04:44.000 [info] Configuring virtual machine
2022-06-24T20:04:44.000 [info] Pulling container image
2022-06-24T20:04:45.000 [info] Unpacking image
2022-06-24T20:04:45.000 [info] Preparing kernel init
2022-06-24T20:04:45.000 [info] Configuring firecracker
2022-06-24T20:04:45.000 [info] Starting virtual machine
2022-06-24T20:04:45.000 [info] [    0.023043] PCI: Fatal: No config space access function found
2022-06-24T20:04:45.000 [info] Starting init (commit: e21acb3)...
2022-06-24T20:04:45.000 [info] Preparing to run: `./webserver` as root
2022-06-24T20:04:45.000 [info] 2022/06/24 20:04:45 listening on [fdaa:0:714b:a7b:b9b7:12ed:bced:2]:22 (DNS: [fdaa::3]:53)
2022-06-24T20:04:45.000 [info] Unhandled exception: Expected config file for the watcher at ./config/watch.yml (Exception)
2022-06-24T20:04:45.000 [info]   from /usr/share/crystal/src/file.cr:650:26 in 'settings'
2022-06-24T20:04:45.000 [info]   from /webserver_build/lib/lucky/src/lucky/server_settings.cr:9:5 in '__crystal_main'
2022-06-24T20:04:45.000 [info]   from /usr/share/crystal/src/crystal/main.cr:115:5 in 'main'
2022-06-24T20:04:45.000 [info]   from src/env/__libc_start_main.c:94:2 in 'libc_start_main_stage2'
2022-06-24T20:04:46.000 [info] Main child exited normally with code: 1
2022-06-24T20:04:46.000 [info] Starting clean up.
***v0 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v1 

It’s crashing because it can’t find a config file for a “watcher”. I’m not super familiar with Lucky, but this sounds like it might be a package that is used for local development.

You may need to tell Lucky it’s running in production, or make sure that library is meant to be installed, or even add the config file it’s asking for.

Hi all! it is my first post here, but I am a huge fan of the services fly.io is building and the Crystal language.

Just wanna mention that the frontpage of https://fly.io incorrectly points the main Crystal-lang logo to
Run a Node App · Fly Docs
where it SHOULD be
Run a Crystal App · Fly Docs

I also submitted an application +CV to work at fly.io as a Ruby developer, would love to help with these projects. Ping the recruiters, please! :wink:

hey @balakhorvathnorbi I’m having the same issue. I have a hunch it has to do with the ENV vars Lucky needs, looking at the heroku guide: Lucky - Deploying to Heroku
it seems maybe we should add LUCKY_ENV, APP_DOMAIN, and SEND_GRID_KEY in fly.toml (via Fly Launch configuration (fly.toml) · Fly Docs), like for me:

# fly.toml

[env]
  LUCKY_ENV = "production"
  APP_DOMAIN = "https://frosty-glitter-6934.fly.dev"
  SEND_GRID_KEY = "unused"

So I added that, and ran into the error:

  Please set the SECRET_KEY_BASE environment variable. You can generate a secret key with 'lucky gen.secret_key'

so I ran lucky gen.secret_key and used that key to set SECRET_KEY_BASE by using fly secrets (via Secrets and Fly Apps · Fly Docs):

fly secrets set SECRET_KEY_BASE=[generated key]

and reran fly deploy, and then I got (I am pretty sure, at least from console anyways) a successful deploy!

Also separately, I wasn’t able to do an API only Lucky app, fly was trying to install stuff with yarn, and broke, so I switched to full from lucky init. Just thought I’d mention that if anyone else was trying Lucky with API instead of full.