Erlang LS in Visual Studio Code can't find include_lib

My project is a rebar 3 app project, i.e. the code is in the src directory, the dependencies are in _build/default/lib/, and includes are in include and _build/default/lib/*/include.

I have this include statement in on one of my source files: -include_lib("common_erlang/include/common.hrl").

My erlang_ls.config file is in the root directory of the project, this is the content:

apps_dirs:
  - "_build/default/lib/*"
include_dirs:
  - "_build/default/lib/*/include"
  - "include

With the include statement as above, I get the error can't find include lib, but the project compiles. If I change the include statement to -include_lib("common.hrl"). the error in vscode goes away, but I get an error when I compile (obviously).

I tried changing the erlang_ls.config file line - "_build/default/lib/*/include" to - "_build/default/lib/" in case the common_erlang/include part of the include statment was causing a problem, but it still couldn't find it.

Is there a problem with my Erlang LS configuration? I copied it from https://erlang-ls.github.io/configuration/ (the config for rebar3 projects). I tried unistatlling and reinstalling the Erlang LS extension but it didn't help.

Upvotes: 3

Views: 541

Answers (1)

Alastair
Alastair

Reputation: 1800

This config worked for me:

apps_dirs:
  - "_build/default/lib/*"
include_dirs:
  - "_build/default/lib/*/include"
  - "_build/default/lib"
  - "include"

Perhaps the trailing slash you had in _build/default/lib/ was an issue.

Upvotes: 1

Related Questions