Skip to content

loadconfig not clearing application env #13246

Closed
@lukaszsamson

Description

@lukaszsamson

Elixir and Erlang/OTP versions

Erlang/OTP 25 [erts-13.2.2.4] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1]

Elixir 1.16.0 (compiled with Erlang/OTP 25)

Operating system

macOS

Current behavior

When loadconfig is called repeatedly it merges application configs instead of overwriting.
Repro:

  1. create an empty mix app
  2. add config/config.exs
  3. add to config
config :logger, foo: 1
  1. in iex run
Mix.start()
Code.compile_file("mix.exs")
Mix.Task.run("loadconfig")
[
  logger: [foo: 1]
]
Application.get_env(:logger, :foo)         
1
  1. rename :foo to :bar
Mix.Task.run("loadconfig")
[
  logger: [bar: 1]
]
Application.get_env(:logger, :bar)         
1
  1. Verify that old key is still in app env
Application.get_env(:logger, :foo)         
1

Originally reported in https://elixirforum.com/t/how-can-i-prevent-the-lsp-from-invoking-my-custom-mix-compiler/59802/6 and followed up in elixir-lsp/elixir-ls#1030

Expected behavior

I'm not sure this is a bug but there is no mention of this behavior in https://hexdocs.pm/mix/1.16.0/Mix.Tasks.Loadconfig.html. This comment states thet the configs are not deep merged

# Loads compile-time configuration, they support imports, and are not deep merged.

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