vscode-zig icon indicating copy to clipboard operation
vscode-zig copied to clipboard

Command 'Format Document With...' resulted in an error

Open papidb opened this issue 1 year ago • 13 comments

Trying to run format document with throws this error:

image

papidb avatar Jun 15 '23 23:06 papidb

Works on my machine, can you provide more info?

Vexu avatar Jun 16 '23 03:06 Vexu

code --version outputs:

1.79.2
695af097c7bd098fbf017ce3ac85e09bbc5dda06
arm64

zig version is 0.10.1

which zig is /opt/homebrew/bin/zig

My vscode settings is

{
    "workbench.colorTheme": "Default Dark Modern",
    "zig.zls.path": "/Users/benjamindaniel/Library/Application Support/Code/User/globalStorage/ziglang.vscode-zig/zls_install/zls",
    "editor.accessibilitySupport": "off",
    "editor.inlineSuggest.enabled": true,
    "redhat.telemetry.enabled": true
}

I only get this error when I run format document with... command with zig

image

papidb avatar Jun 16 '23 07:06 papidb

which zig is /opt/homebrew/bin/zig

Hmm, is that a symlink? This might be a duplicate of #34.

Vexu avatar Jun 16 '23 15:06 Vexu

I used homebrew to install zig.

papidb avatar Jun 16 '23 22:06 papidb

Does homebrew install symlinks? If yes running file /opt/homebrew/bin/zig should give a path to the link target, can you try setting that as zigPath and seeing if formatting works then?

Vexu avatar Jun 18 '23 05:06 Vexu

Running file /opt/homebrew/bin/zig gives /opt/homebrew/bin/zig: Mach-O 64-bit executable arm64 so I don't think it did install symlinks.

papidb avatar Jun 18 '23 13:06 papidb

And just to make sure, your zig.zigPath is set to that path? And plain format document (no with) works?

Vexu avatar Jun 18 '23 16:06 Vexu

Observing the same behavior:

  • downloaded zig (0.11.0-dev.3704+729a051e9)
  • added zig to PATH
  • point zig.zigPath to the zig binary

Format Document With... throws the Cannot read properties of undefined error. Format Document doesn't seem to be doing anything.

tomwyr avatar Jun 19 '23 16:06 tomwyr

Are you also on macos?

Vexu avatar Jun 19 '23 16:06 Vexu

Trying to download zig with vscode throws the error: image

vscode also displays the warning: image

papidb avatar Jun 19 '23 18:06 papidb

The first issue was fixed in https://github.com/ziglang/vscode-zig/commit/1b6dfd19550eed115117ee7c2fb6c4625db54fca and the second is tracked in #86.

Vexu avatar Jun 19 '23 19:06 Vexu

@Vexu I'm on macos, yes.

tomwyr avatar Jun 19 '23 19:06 tomwyr

@Vexu yes I am on macOS, M1.

papidb avatar Jun 21 '23 19:06 papidb