Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zls is broken in bun's repo #1396

Closed
Jarred-Sumner opened this issue Aug 10, 2023 · 4 comments · Fixed by #1411
Closed

zls is broken in bun's repo #1396

Jarred-Sumner opened this issue Aug 10, 2023 · 4 comments · Fixed by #1411
Labels
bug Something isn't working

Comments

@Jarred-Sumner
Copy link
Contributor

Jarred-Sumner commented Aug 10, 2023

Zig Version

0.11.0-dev.4006+bf827d0b5

Zig Language Server Version

HEAD (latest published to VSCode)

Steps to Reproduce

  1. gh clone oven-sh/bun
  2. Open a .zig file which uses the bun identifier (almost all of them)
  3. No completions appear.

Looks like zls is failing to load build.zig in bun's repository. This started happening yesterday or today. I don't think we made any relevant changes.

Any identifiers which reference an import no longer have completions
image

Note that bun here is const bun = @import("root").bun. The @import("root") seems to not resolve, most likely due to failing to load build.zig.

Relevant log (note the invalid unicode character):

error: (store ): Failed to execute build runner to collect build configuration, command:
�info : (server): Setting configuration...

Complete log:

info : ( main ): Starting ZLS 0.12.0-dev.2+9532f4a @ '/Users/jarred/Library/Application Support/Code/User/globalStorage/ziglang.vscode-zig/zls_install/zls'
info : (config): Using zig executable '/Users/jarred/zig/master/files/zig'
info : (config): Using zig lib path '/Users/jarred/zig/0.11.0-dev.4006+bf827d0b5/files/lib'
info : (config): Using build runner global cache path '/Users/jarred/.cache/zig'
info : (config): Detected runtime zig version: '0.11.0-dev.4006+bf827d0b5'
info : (server): client is 'Visual Studio Code-1.81.0'
info : (server): zls initializing
info : (server): Server.ClientCapabilities{ .supports_snippets = true, .supports_apply_edits = true, .supports_will_save = true, .supports_will_save_wait_until = true, .supports_publish_diagnostics = true, .supports_code_action_fixall = true, .hover_supports_md = true, .completion_doc_supports_md = true, .label_details_support = true, .supports_configuration = true, .supports_workspace_did_change_configuration_dynamic_registration = true, .supports_textDocument_definition_linkSupport = true }
info : (server): Using offset encoding: utf-16
warning: (server): Zig `0.11.0-dev.4006+bf827d0b5` is older than ZLS `0.12.0-dev.2+9532f4a`. Update Zig to avoid unexpected behavior.
info : (server): Setting configuration...
warning: (server): Ignoring new value for "zls.record_session_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.replay_session_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.builtin_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.build_runner_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.global_cache_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.build_runner_global_cache_path": the given new value is invalid
info : (config): Using zig executable '/Users/jarred/zig/master/files/zig'
info : (config): Using zig lib path '/Users/jarred/zig/0.11.0-dev.4006+bf827d0b5/files/lib'
info : (config): Using build runner global cache path '/Users/jarred/.cache/zig'
info : (config): Detected runtime zig version: '0.11.0-dev.4006+bf827d0b5'
error: (store ): Failed to execute build runner to collect build configuration, command:
�info : (server): Setting configuration...
warning: (server): Ignoring new value for "zls.record_session_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.replay_session_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.builtin_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.build_runner_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.global_cache_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.build_runner_global_cache_path": the given new value is invalid
info : (config): Using zig executable '/Users/jarred/zig/master/files/zig'
info : (config): Using zig lib path '/Users/jarred/zig/0.11.0-dev.4006+bf827d0b5/files/lib'
info : (config): Using build runner global cache path '/Users/jarred/.cache/zig'
info : (config): Detected runtime zig version: '0.11.0-dev.4006+bf827d0b5'
info : (server): Setting configuration...
warning: (server): Ignoring new value for "zls.record_session_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.replay_session_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.builtin_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.build_runner_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.global_cache_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.build_runner_global_cache_path": the given new value is invalid
info : (config): Using zig executable '/Users/jarred/zig/master/files/zig'
info : (config): Using zig lib path '/Users/jarred/zig/0.11.0-dev.4006+bf827d0b5/files/lib'
info : (config): Using build runner global cache path '/Users/jarred/.cache/zig'
info : (config): Detected runtime zig version: '0.11.0-dev.4006+bf827d0b5'
info : (server): Setting configuration...
warning: (server): Ignoring new value for "zls.record_session_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.replay_session_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.builtin_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.build_runner_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.global_cache_path": the given new value is invalid
warning: (server): Ignoring new value for "zls.build_runner_global_cache_path": the given new value is invalid
info : (config): Using zig executable '/Users/jarred/zig/master/files/zig'
info : (config): Using zig lib path '/Users/jarred/zig/0.11.0-dev.4006+bf827d0b5/files/lib'
info : (config): Using build runner global cache path '/Users/jarred/.cache/zig'
info : (config): Detected runtime zig version: '0.11.0-dev.4006+bf827d0b5'
warning: (store ): Document already open: file:///Users/jarred/Code/bun/src/bun.js/javascript.zig

Expected Behavior

Completions should appear for imports.

Actual Behavior

Completions do not appear for imports.

@Jarred-Sumner Jarred-Sumner added the bug Something isn't working label Aug 10, 2023
@llogick
Copy link
Contributor

llogick commented Aug 10, 2023

A change was made to build_runner.zig in 9532f4a, basically HEAD, to expand package resolution.
I did report an issue with it and there's a PR to address it #1394, could you try and see if it works for you?

If not, could you post the output of zig build --build-runner ~/.cache/zls/build_runner.zig (ran in the project's folder).

@Jarred-Sumner
Copy link
Contributor Author

A change was made to build_runner.zig in 9532f4a, basically HEAD, to expand package resolution. I did report an issue with it and there's a PR to address it #1394, could you try and see if it works for you?

If not, could you post the output of zig build --build-runner ~/.cache/zls/build_runner.zig (ran in the project's folder).

/Users/jarred/Build/zls/src/special/build_runner.zig:321:31: error: root struct of file 'Build' has no member named 'LazyPath'
    fn getPath(path: std.Build.LazyPath, builder: *Build) ?[]const u8 {
                     ~~~~~~~~~^~~~~~~~~
referenced by:
    processStep: /Users/jarred/Build/zls/src/special/build_runner.zig:228:28
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

The issue is that Zig has breaking changes between the build we're on (a couple weeks before 0.11.0) and $HEAD.

zls randomly stopped working due to breaking changes in build.zig.

Instead of executing the build.zig file with the version of zig used by zls, have you considered executing it with the local zig version used in the project?

@llogick
Copy link
Contributor

llogick commented Aug 12, 2023

I agree that pushing out a nightly build to everyone that uses the extension isn't ideal, but as a 3rd party I can only direct you to the
relevant issue ziglang/vscode-zig#82 to express your opinion so they'd prioritize it.

Instead of executing the build.zig file with the version of zig used by zls, have you considered executing it with the local zig version used in the project?

That is already the case, which, in theory, means that grabbing the previous src/special/build_runner.zig+ setting zls.build_runner_path
should address your use case

Cheers

@Jarred-Sumner
Copy link
Contributor Author

That is already the case, which, in theory, means that grabbing the previous src/special/build_runner.zig+ setting zls.build_runner_path
should address your use case

Ah, so the next time ZLS randomly breaks when I open VSCode, the process is:

  1. Figure out the last working ZLS version
  2. Copy build_runner.zig from that version into the new version
  3. Retry

Is that correct?

Wouldn't it make more sense for:

  1. ZLS to keep previous versions of build_runner.zig and execute the one compatible with the local version of Zig
  2. Change the auto-updater to track which versions of Zig ZLS is compatible with and only update to the latest ZLS compatible with the local version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants