kamal icon indicating copy to clipboard operation
kamal copied to clipboard

Empty ENV vars choke crontab when deploying as cron role

Open edmz opened this issue 2 months ago • 0 comments

A recent PR #1634 added KAMAL_DESTINATION to the Docker container env vars, which is an ENV variable that is not always populated.

If you happen to have a cron role and follow the documentation suggestion of setting up cron like so:

servers:
  cron:
    hosts:
      - 192.168.0.1
    cmd:
      bash -c "(env && cat config/crontab) | crontab - && cron -f"

You would end up with a concatenation of all the env vars plus your crontab, but KAMAL_DESTINATION would be empty and crontab chokes on this, with the following error:

"-":20: bad minute

We have to change the documentation to alert the users to be cautious of not having empty environment variables and/or also change the suggested cmd to filter empty ones.

It might also be a good idea to not set KAMAL_DESTINATION if config.destination is empty in lib/commands/app.rb.

More background on https://github.com/basecamp/kamal/discussions/1635

edmz avatar Nov 04 '25 16:11 edmz