zls icon indicating copy to clipboard operation
zls copied to clipboard

Failure loading imported modules suffixed with `.zig`

Open GalaxyShard opened this issue 4 months ago • 0 comments

Zig Version

0.15.1

ZLS Version

0.16.0-dev.1+35fa2d3e

Client / Code Editor / Extensions

Kate

Steps to Reproduce and Observed Behavior

Run zig init in an empty directory and apply the following two changes:

diff --git a/build.zig b/build.zig
index c6c121e..317d5a4 100644
--- a/build.zig
+++ b/build.zig
@@ -78,7 +78,7 @@ pub fn build(b: *std.Build) void {
                 // repeated because you are allowed to rename your imports, which
                 // can be extremely useful in case of collisions (which can happen
                 // importing modules from different packages).
-                .{ .name = "issue", .module = mod },
+                .{ .name = "issue.zig", .module = mod },
             },
         }),
     });
diff --git a/src/main.zig b/src/main.zig
index 26c5d0a..8613281 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -1,5 +1,5 @@
 const std = @import("std");
-const issue = @import("issue");
+const issue = @import("issue.zig");
 
 pub fn main() !void {
     // Prints to stderr, ignoring potential errors.

Zls outputs the following error:

[Error] failed to read document '/home/galaxyshard/projects/issue/src/issue.zig': error.FileNotFound

whereas zig build successfully runs.

Expected Behavior

Zls should attempt to find a module with the given name.

Log Output


GalaxyShard avatar Aug 31 '25 05:08 GalaxyShard