Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile_env error seems wrong #1008

Closed
AHBruns opened this issue Oct 20, 2023 · 7 comments
Closed

compile_env error seems wrong #1008

AHBruns opened this issue Oct 20, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@AHBruns
Copy link

AHBruns commented Oct 20, 2023

Precheck

  • Do a quick search and make sure the issue has not yet been reported
  • Do not use the issues tracker for guidance, questions or support (try Elixir Forum, Stack Overflow, Slack, etc. instead)
  • If using a client other than VS Code, please try VSCode's "ElixirLS: Elixir support and debugger" extension. Does it reproduce your failure?

Environment

  • Elixir & Erlang versions (elixir --version):
    Erlang/OTP 26 [erts-14.0.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit] [dtrace]
    Elixir 1.15.5 (compiled with Erlang/OTP 26)
  • Elixir Language Server version:
    how can I determine this?
  • Operating system:
    Mac
  • Editor or IDE name (e.g. Emacs/VSCode):
    VSCode
  • Editor Plugin/LSP Client name and version:
    ElixirLS: Elixir support and debugger v0.17.1

Current behavior

I have a module:

defmodule Grimoire.Bridges.HubspotClient do
  @base_url Application.compile_env!(:grimoire, [Grimoire.Bridges.Hubspot, :base_url])

I get this error:

(ArgumentError) could not fetch application environment [Grimoire.Bridges.Hubspot, :base_url] for application :grimoire because the application was not loaded nor configured

Stacktrace:
  │ (elixir 1.15.5) lib/application.ex:635: Application.compile_env!/3
  │ lib/grimoire/bridges/hubspot/hubspot_client.ex:10: (module)Elixir

here's the corresponding ElixirLS log:

[Warn  - 3:45:28 AM] 
== Compilation error in file lib/grimoire/bridges/hubspot/hubspot_client.ex ==
** (ArgumentError) could not fetch application environment [Grimoire.Bridges.Hubspot, :base_url] for application :grimoire because the application was not loaded nor configured
    (elixir 1.15.5) lib/application.ex:635: Application.compile_env!/3
    lib/grimoire/bridges/hubspot/hubspot_client.ex:10: (module)

The issue is that, the error does seem to be accurate. I can compile my application without any warnings, or issues. Just to confirm, this is in my application's config.exs file:

config :grimoire, Grimoire.Bridges.Hubspot,
  base_url: "****",

Expected behavior

No error

@lukaszsamson
Copy link
Collaborator

Please create a small repro and fill the error template

@tuomohopia
Copy link

I'm getting this too for using the same Application function. It seems like Elixir LS is failing whenever it's trying to compile code that is relying on the application configs.

@lukaszsamson lukaszsamson added bug Something isn't working and removed waiting for information labels Oct 20, 2023
@lukaszsamson
Copy link
Collaborator

I reproduced it. Most likely the problem was introduced in d9cc23a. I need to look for another workaround for elixir-lang/elixir#13001

@AHBruns
Copy link
Author

AHBruns commented Oct 20, 2023

I couldn't make a reliable reproduction in a smaller app. It sometimes happened, but seemingly randomly.

@lud-wj
Copy link

lud-wj commented Jan 21, 2024

I had the same issue until I put my configuration directly in the code to avoid it.

On my machine is was systematical, but not on the first compilation.

So basically if I run rm -rf .elixir_ls and restart vscode, everything is fine. Then if I change any module, the error shows.

@lukaszsamson
Copy link
Collaborator

@lud-wj please create a repro

@lud-wj
Copy link

lud-wj commented Jan 22, 2024

I am not reproducing. I reverted my change in my real codebase to see if that pops up again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants