Skip to content

Missing secret env when merging two deploy.yml files #1749

@jrodriigues

Description

@jrodriigues

I am using kamal to deploy a rails 8 application. I have a custom environment, staging, and created the respective config/deploy.staging.yml configuration file.

This is my config/deploy.yml env settings:

env:
  clear:
    RAILS_ENV: production
  secret:
    - RAILS_MASTER_KEY

And this is my config/deploy.staging.yml:

env:
  clear:
    RAILS_ENV: staging
  secret:
    - DATABASE_URL

When deploying with kamal deploy -d staging, I would expect that the secret envs would be merged, ending up with RAILS_MASTER_KEY and DATABASE_URL in my container. However, that's not the case.

When I run the above command, the deployment fails with the following error:

2026-01-08T16:46:03.487349794Z ArgumentError: Missing `secret_key_base` for 'staging' environment, set this string with `bin/rails credentials:edit` (ArgumentError)
2026-01-08T16:46:03.487360669Z
2026-01-08T16:46:03.487364601Z           raise ArgumentError, "Missing `secret_key_base` for '#{Rails.env}' environment, set this string with `bin/rails credentials:edit`"
2026-01-08T16:46:03.487368438Z                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2026-01-08T16:46:03.487371979Z /rails/config/environment.rb:5:in `<main>'

If I add the RAILS_MASTER_KEY explicitly to config/deploy.staging/yml and alongside DATABASE_URL, then the deployment works as expected.

Is this expected behaviour? I couldn't find any documentation that supports it.

Versions:

  • kamal 2.10.1
  • rails 8.0.4
  • ruby 3.3.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions