Skip to content

simlinks break @import resolution #3182

@thrombe

Description

@thrombe

Zig Version

0.16.0

ZLS Version

0.16.0

Client / Code Editor / Extensions

helix

Steps to Reproduce and Observed Behavior

  • clone https://github.com/thrombe/zls
  • git checkout import-bugs
  • cd examples/simlink
  • open code editor (in my case, helix)
  • trigger goto definition on @import("vulkan"). it fails

but

  • cd examples/simlinked
  • open code editor
  • trigger goto definition on @import("vulkan")
  • this time, it resolves correctly

more detailed instructions and issue explation after my debugging.
https://github.com/thrombe/zls/blob/import-bugs/examples/simlinked/README.md

Expected Behavior

goto definition should work even when projects are opened via simlinks.
we know the setup is correct because zig build run works fine.

Attach ZLS log output

logs after opening main.zig via examples/simlink and triggering goto definition on @import("vulkan") a few times

zls.log
info  ( main ): Starting ZLS      0.16.0 @ '/nix/store/gyznl9c2gb73126ricbv96dsd673b5b1-zls/bin/zls'
info  ( main ): Log File:         /home/issac/.cache/zls/zls.log (info)
info  ( main ): Loaded config:    /home/issac/.config/zls.json
info  (server): Client Info:      helix (25.07.1 (a05c151b))
info  (server): added Workspace Folder: file:///home/issac/daata/repos/checkout/code_read/zls/examples/simlink (2 files)
info  (server): Set config option 'build_on_save_args' to ["-fincremental"]
info  (server): Set config option 'builtin_path' to "/home/issac/.cache/zls/builtin.zig"
info  (server): Set config option 'zig_lib_path' to "/nix/store/19cahh4irrwrj16dl4sbzll0ygn406ap-zig-0.16.0/lib"
info  (server): Set config option 'zig_exe_path' to "/nix/store/19cahh4irrwrj16dl4sbzll0ygn406ap-zig-0.16.0/bin/zig"
info  (server): Set config option 'build_runner_path' to "/home/issac/.cache/zls/build_runner/0536d83f23cda18cf0a02d9cd4e6dce4/build_runner.zig"
info  (server): Set config option 'global_cache_path' to "/home/issac/.cache/zls"
info  (store ): Loaded build file 'file:///home/issac/daata/repos/checkout/code_read/zls/examples/simlink/build.zig'
info  (store ): Loaded build file 'file:///home/issac/daata/repos/checkout/code_read/zls/build.zig'

after adding a log just above this line

zls.log
info  ( main ): Starting ZLS      0.16.0 @ '/home/issac/daata/repos/checkout/code_read/zls/zig-out/bin/zls'
info  ( main ): Log File:         /home/issac/.cache/zls/zls.log (debug)
info  ( main ): Loaded config:    /home/issac/.config/zls.json
info  (server): Client Info:      helix (25.07.1 (a05c151b))
debug (server): Offset Encoding:  'utf-8'
info  (server): added Workspace Folder: file:///home/issac/daata/repos/checkout/code_read/zls/examples/simlink (2 files)
debug (server): Dynamically registering method 'workspace/didChangeWatchedFiles'
info  (server): Set config option 'build_on_save_args' to ["-fincremental"]
info  (server): Set config option 'builtin_path' to "/home/issac/.cache/zls/builtin.zig"
info  (server): Set config option 'zig_lib_path' to "/nix/store/19cahh4irrwrj16dl4sbzll0ygn406ap-zig-0.16.0/lib"
info  (server): Set config option 'zig_exe_path' to "/nix/store/19cahh4irrwrj16dl4sbzll0ygn406ap-zig-0.16.0/bin/zig"
info  (server): Set config option 'build_runner_path' to "/home/issac/.cache/zls/build_runner/0536d83f23cda18cf0a02d9cd4e6dce4/build_runner.zig"
info  (server): Set config option 'global_cache_path' to "/home/issac/.cache/zls"
info  (store ): Loaded build file 'file:///home/issac/daata/repos/checkout/code_read/zls/examples/simlink/build.zig'
info  (store ): Loaded build file 'file:///home/issac/daata/repos/checkout/code_read/zls/build.zig'
debug (default): association resolution file:///home/issac/daata/repos/checkout/code_read/zls/examples/simlink/src/main.zig file:///home/issac/daata/repos/checkout/code_read/zls/examples/simlinked/.zig-cache/o/afde9d823e24ab77099cb5a57ee85275/vk.zig
debug (default): association resolution file:///home/issac/daata/repos/checkout/code_read/zls/examples/simlink/src/main.zig file:///home/issac/daata/repos/checkout/code_read/zls/examples/simlinked/zig-pkg/vulkan-0.0.0-r7YtxyBsAwD35FvkFhT2xruTNdCByD3TtGw44XWtfun8/src/main.zig
debug (default): association resolution file:///home/issac/daata/repos/checkout/code_read/zls/examples/simlink/src/main.zig file:///home/issac/daata/repos/checkout/code_read/zls/examples/simlinked/zig-pkg/vulkan-0.0.0-r7YtxyBsAwD35FvkFhT2xruTNdCByD3TtGw44XWtfun8/src/vulkan/generator.zig
debug (default): association resolution file:///home/issac/daata/repos/checkout/code_read/zls/examples/simlink/src/main.zig file:///home/issac/daata/repos/checkout/code_read/zls/examples/simlinked/zig-pkg/vulkan-0.0.0-r7YtxyBsAwD35FvkFhT2xruTNdCByD3TtGw44XWtfun8/src/xml.zig
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions