Skip to main content

W0058 - Can't find include file

Error​

-module(example).

-include("missing_header.hrl").
%% error: W0058: can't find include file "missing_header.hrl"

-include_lib("missing_app/include/header.hrl").
%% error: W0058: can't find include lib "missing_app/include/header.hrl"

This diagnostic is triggered when an include file referenced by -include() or -include_lib() cannot be resolved by the ELP native diagnostic processing. The file path cannot be found in the search paths available to ELP.

Important: This diagnostic corresponds to Erlang service diagnostic E1516 (can't find include file/lib). W0058 only appears when the corresponding Erlang service diagnostic does not appear. If you see W0058 in a Buck project, it is likely a sign that the project is not defined properly in your TARGETS file.

Common Causes​

  1. Missing file: The include file does not exist at the specified path.
  2. Incorrect path: The path to the include file is incorrect or misspelled.
  3. Missing application dependency: For -include_lib(), the referenced application is not listed as a dependency.
  4. Incorrect include path configuration: The directory containing the header file is not in the configured include paths.

Fix​

Verify the file exists​

Make sure the include file exists at the expected location.

Fix the path​

Correct the path to match the actual file location:

-module(example).

% Correct path to the include file
-include("correct_header.hrl").

% Correct application name and path
-include_lib("correct_app/include/header.hrl").

Add missing dependency​

For -include_lib(), ensure the application is listed as a dependency in your build configuration:

rebar.config:

{deps, [
missing_app
]}.

Buck TARGETS file:

erlang_app(
name = "my_app",
deps = [
"//path/to:missing_app",
],
)

Configure include paths​

Ensure the directory containing the header file is in your project's include paths configuration.

Relationship to Erlang Service Diagnostics​

W0058 is filtered out when the Erlang service reports the corresponding diagnostic:

  • E1516: can't find include file/lib

When both diagnostics detect the same issue, only the Erlang service diagnostic will be shown to avoid duplication.

Buck Project Configuration​

If you see W0058 in a Buck project, this typically indicates that your TARGETS file is not properly configured. The Erlang service relies on Buck to understand the project structure, dependencies, and include paths. Check that:

  • All application dependencies are declared in the deps attribute
  • For -include_lib() directives, the referenced application is included as a dependency
  • Include paths are properly configured with the include or include_lib attributes
  • The header file is defined in a dependency of the buck target holding the current file