I’m struggling to understand an error I’m seeing when deploying an Elixir app with releases. The error looks like this:
remote: ! Release command declared: '/app/bin/backend eval "Backend.Release.migrate()"' remote: ERROR! the application :backend has a different value set for key :basic_auth during runtime compared to compile time. Since this application environment entry was marked as compile time, this difference can lead to different behaviour than expected: remote: * Compile time value was not set remote: * Runtime value was set to: [username: "admin", admin_password: "<snip>"] remote: To fix this error, you might: remote: * Make the runtime value match the compile time one remote: * Recompile your project. If the misconfigured application is a dependency, you may need to run "mix deps.compile backend --force" remote: * Alternatively, you can disable this check. If you are using releases, you can set :validate_compile_env to false in your release configuration. If you are using Mix to start your system, you can pass the --no-validate-compile-env flag
releases.ex, I have the following:
admin_password = System.get_env("ADMIN_PASSWORD") || raise """ environment variable ADMIN_PASSWORD is missing. """ config :backend, :basic_auth, username: "admin", admin_password: admin_password
The error seems to be that the compile-time and runtime configuration are different. I tried setting the same configuration with hardcoded test values in
config.exs, but this gives the same issue since the hardcoded values are different from my actual production
I couldn’t find much documentation on this – I know I can set
false, but is this recommended? Can I resolve this error without disabling this feature?