Fake error from LS for custom config filename

Elixir: ** (ArgumentError) could not fetch application environment [Plug.Static, :from] for application :softer because configuration at [Plug.Static, :from] was not set
    (elixir 1.17.3) lib/application.ex:638: Application.compile_env!/3
    lib/pillars/plug.ex:8: (module)
    (elixir 1.17.3) lib/kernel/parallel_compiler.ex:429: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/8
# Error here
defmodule Pillars.Plug do
  use Plug.Router

  if Mix.env() == :dev do
    use Plug.Debugger, otp_app: :pillars
  end

  @external_resource Application.compile_env!(:softer, [Plug.Static, :from])
  plug Plug.Static, Application.compile_env!(:softer, Plug.Static)
  plug Plug.Parsers, Application.compile_env!(:softer, Plug.Parsers)
  plug Plug.Session, Application.compile_env!(:softer, Plug.Session)

# ...

I’m getting this error from the code editor when [Plug.Static, :from] works fine actually. I think it’s because config is config/build.exs instead of config/config.exs.

def project do
  [
    elixir: "~> 1.17",
    build_path: umbrella("_build"),
    config_path: umbrella("config/build.exs"),
    # ...
  ]
end

The error disappears if I change it to config/config.exs. Can I keep its name customised and make the error message gone?

  • elixir-ls: stable 0.23.0
  • Erlang/OTP 27
  • Elixir 1.17.3 (compiled with Erlang/OTP 27)
  • Zed 0.155.2
"lsp": {
  "elixir-ls": {
    "settings": {
      "autoBuild": false
    }
  }
},

Silences it effectively. But I don’t want to give up auto-build all together

Reproduction:

mix new mix_new --umbrella
cd mix_new/apps
mix new hello
--- config/config.exs
+++ config/build.exs

@@ config/build.exs @@
+ config :hello, :world, "hello, world"

@@ apps/hello/mix.exs @@
- config_path: "../../config/config.exs",
+ config_path: "../../config/build.exs",

@@ apps/hello/lib/hello.ex @@
+ @config Application.compile_env!(:hello, :world)

And let ElixirLS auto-build

Adding :config_path in umbrella mix solved it. It was because ElixirLS mix compile on the umbrella level.

@@ mix.exs @@
defmodule Softer.Umbrella.Project do
  use Mix.Project

  def project do
    [
      apps_path: "apps",
+     config_path: "config/build.exs"
    ]
  end
end