# ZLS not pulling in information from dependencies

**URL:** <https://ziggit.dev/t/zls-not-pulling-in-information-from-dependencies/4179>\
**Category:** Help\
**Tags:** package-management, zls\
**Created:** [May 3, 2024, 1:59am UTC](https://ziggit.dev/t/zls-not-pulling-in-information-from-dependencies/4179 "2024-05-03T01:59:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Calder-Ty](https://ziggit.dev/user_avatar/ziggit.dev/calder-ty/32/10237_2.png) [@Calder-Ty](https://ziggit.dev/u/Calder-Ty)\
**Post date:** [May 3, 2024, 1:59am UTC](https://ziggit.dev/t/zls-not-pulling-in-information-from-dependencies/4179/1 "2024-05-03T01:59:04Z")

</div>

I’m starting to use packages. However when I add a dependency and start using it I’m unable to get any language server information (e.g, go to definition, function declaration information, completion suggestions) about the third party package. Is this a feature that ZLS doesn’t support yet, or am i just configuring wrong?

build.zig

```zig
    const exe = b.addExecutable(.{
        .name = "multihash",
        .root_source_file = .{ .path = "src/main.zig" },
        .target = target,
        .optimize = optimize,
    });

    const clap_dep = b.dependency("clap", .{});
    exe.root_module.addImport("clap", clap_dep.module("clap"));

    // This declares intent for the executable to be installed into the
    // standard location when the user invokes the "install" step (the default
    // step when running `zig build`).
    b.installArtifact(exe);

```

build.zig.zon

```zig
.{
    .name = "multihash",
    // This is a [Semantic Version](https://semver.org/).
    // In a future version of Zig it will be used for package deduplication.
    .version = "0.12.0",

    // This field is optional.
    // This is currently advisory only; Zig does not yet do anything
    // with this value.
    .minimum_zig_version = "0.12.0-dev.3158+1e67f5021",

    // This field is optional.
    // Each dependency must either provide a `url` and `hash`, or a `path`.
    // `zig build --fetch` can be used to fetch all dependencies of a package, recursively.
    // Once all dependencies are fetched, `zig build` no longer requires
    // internet connectivity.
    .dependencies = .{
        .clap = .{
            .url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.8.0.tar.gz",
            .hash = "1220949d4e88864579067b6d4cdad6476c6176f27e782782c2c39b7f2c4817a10efb",
        },
    },
    .paths = .{
        // This makes *all* files, recursively, included in this package. It is generally
        // better to explicitly list the files and directories instead, to insure that
        // fetching from tarballs, file system paths, and version control all result
        // in the same contents hash.
        "build.zig",
        "build.zig.zon",
        "src",
        "LICENSE",
        "README.md",
    },
}

```

I’m using neovim as my editor, and have zls configured as so (using nvim-lspconfig):

```zig
local zig_opts = {
	flags = {
		debounce_text_changes = 150,
	},
	settings = {
		zls = {
			warn_style=true,
			inlay_hints_show_variable_type_hints=true,
		}
	},
}

```

---

<div class="post-metadata">

**Author:** ![Sze](https://ziggit.dev/user_avatar/ziggit.dev/sze/32/496_2.png) [@Sze](https://ziggit.dev/u/Sze)\
**Post date:** [May 3, 2024, 10:04am UTC](https://ziggit.dev/t/zls-not-pulling-in-information-from-dependencies/4179/2 "2024-05-03T10:04:09Z")

</div>

Check whether `:LspLog` shows errors. Also for me it shows a bunch of info messages of the style `Set config option 'enable_autofix' to 'true'`, I imagine those would be missing if the config doesn’t work.

> **my lazy config**
>
> ```zig
> return {
> {
> "neovim/nvim-lspconfig",
> init = function()
> require("lspconfig")["zls"].setup({
> settings = {
> zls = {
> path = "/home/sze/development/workspace/zig/active/current/zig",
> zls = {
> path = "/home/sze/development/workspace/zig/active/zls/zig-out/bin/zls",
> enable_snippets = true,
> enable_ast_check_diagnostics = true,
> enable_autofix = true,
> enable_import_embedfile_argument_completions = true,
> warn_style = true,
> enable_semantic_tokens = true,
> enable_inlay_hints = true,
> inlay_hints_hide_redundant_param_names = true,
> inlay_hints_hide_redundant_param_names_last_token = true,
> operator_completions = true,
> include_at_in_builtins = true,
> max_detail_length = 1048576,
> },
> },
> },
> })
> end,
> },
> }
> 
> ```

---

<div class="post-metadata">

**Author:** ![smallkirby](https://ziggit.dev/user_avatar/ziggit.dev/smallkirby/32/2291_2.png) [@smallkirby](https://ziggit.dev/u/smallkirby)\
**Post date:** [May 3, 2024, 10:07am UTC](https://ziggit.dev/t/zls-not-pulling-in-information-from-dependencies/4179/3 "2024-05-03T10:07:35Z")

</div>

I’m not familiar with Zig, but I had the same problem and found that my ZLS version was `0.11.0` while Zig is `0.12.0`. After updating ZLS, it worked perfectly for me. It might help you to check if your ZLS is up to date or matches your Zig version.

---

<div class="post-metadata">

**Author:** ![clseibold](https://ziggit.dev/user_avatar/ziggit.dev/clseibold/32/4879_2.png) [@clseibold](https://ziggit.dev/u/clseibold)\
**Post date:** [April 17, 2025, 1:35pm UTC](https://ziggit.dev/t/zls-not-pulling-in-information-from-dependencies/4179/4 "2025-04-17T13:35:02Z")

</div>

I have recently had a similar problem, and what fixed it for me was adding the dependency/import directly on the `exe_mod` before defining `exe` rather than adding it to `exe.root_module` after defining `exe`.

The libvaxis documentation suggests doing the following, which, while it compiles, completely messes up ZLS’s completion of the module:

```zig
    const exe = b.addExecutable(.{
        .name = "multilect",
        .root_module = exe_mod,
    });
    // LibVaxis Dependency
    const vaxis = b.dependency("vaxis", .{
        .target = target,
        .optimize = optimize,
    });

    exe.root_module.addImport("vaxis", vaxis.module("vaxis"));

```

Here’s what I do now instead, and this fixes ZLS’s completion for me:

```zig
    // main.zig module
    const exe_mod = b.createModule(.{
        .root_source_file = b.path("src/main.zig"),
        .target = target,
        .optimize = optimize,
    });

    exe_mod.addImport("multilect_lib", lib_mod);

    // LibVaxis Dependency
    const vaxis = b.dependency("vaxis", .{
        .target = target,
        .optimize = optimize,
    });

    exe_mod.addImport("vaxis", vaxis.module("vaxis"));

    // exe defined below here

```
