biomejs / biome-vscode

Biome extension for Visual Studio Code and VSCodium
https://marketplace.visualstudio.com/items?itemName=biomejs.biome
Apache License 2.0
229 stars 31 forks source link

🐛 "Cannot open shim file for read." when using biome-win32-x64.exe #389

Open LucasOe opened 3 weeks ago

LucasOe commented 3 weeks ago

VS Code version

1.94.1

Extension version

2024.10.40751 (pre-release)

Biome version

1.9.3

Operating system

Description

Biome language server fails to initialize when installed via Scoop on Windows. This issue results in two error notifications:

biome client: couldn't create connection to server.

Biome language server closed

This issue only happens with the pre-release version. The Release version can find the biome.exe shim:

Biome found in PATH: c:\Users\lucas\scoop\shims\biome.exe Biome binary found at c:\Users\lucas\scoop\shims\biome.exe Executing Biome from: c:\Users\lucas\scoop\shims\biome.exe

Steps to reproduce

  1. Install Scoop on Windows
  2. Install biome using scoop install biome. Make sure the biome.exe shim is in your PATH.
  3. Install the Biome Extension for VSCode and switch to the pre-release version
  4. Open single file in VSCode, or a directory if biome.requireConfigFile is set to false (#390)
  5. Observe error notifications and check the Output panel for logs

Expected behavior

The Biome language server should start successfully, and Biome-related functionalities should work without errors.

Does this issue occur when using the CLI directly?

Not sure / Not applicable

Link to a minimal reproduction

No response

Logs

Biome:
>  2024-10-09 23:48:30.263 [info] Biome extension 2024.10.40751 activated
> 2024-10-09 23:48:30.463 [error] Failed to initialize the Biome language server
>   error=Error: Pending response rejected since connection got disposed
> 2024-10-09 23:48:30.463 [error] Failed to start Biome extension
> 2024-10-09 23:48:30.464 [info] Biome extension started
> 2024-10-09 23:48:30.464 [info] User-facing commands registered
> 2024-10-09 23:48:30.464 [info] Started listening for lockfile changes
> 2024-10-09 23:48:30.464 [info] Started listening for configuration changes
> 2024-10-09 23:48:30.465 [info] Started listening for active text editor changes

Biome LSP (global session):
> 2024-10-09 23:48:30.460 [info] Cannot open shim file for read.
> Could not read shim file.
> 
> 2024-10-09 23:48:30.463 [info] [Error - 11:48:30 PM] Biome language server closed
> 2024-10-09 23:48:30.463 [info] [Error - 11:48:30 PM] biome client: couldn't create connection to server.
> 2024-10-09 23:48:30.463 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097
nhedger commented 3 weeks ago

Not a Windows user myself, so any help here would be appreciated.

Also, are we certain that this is an issue with Biome, and not Scoop itself.

2024-10-09 23:48:30.460 [info] Cannot open shim file for read. Could not read shim file.

This seems like an error that Scoop would print out.

LucasOe commented 2 weeks ago

Not a Windows user myself, so any help here would be appreciated.

If Biome is installed through Scoop, the binary gets downloaded GitHub, and extracted to a directory. To keep your environment variables clean, it creates a shim for the biome.exe and adds it to your PATH. I suspect that the pre-release version of the extension has problems working with this shim. I don't know why that would be.

Also, are we certain that this is an issue with Biome, and not Scoop itself.

The release version of the extension seems to handle shims just fine. I can run biome through the command line, so the shim created by Scoop seems to work.

This issue probably isn't specific to Scoop, but to any shim for the biome.exe. Though I would not expect users to create a shim outside of the use with a package manager.

This seems like an error that Scoop would print out.

Scoop itself doesn't print any errors from what I know, all it does is download the binary and create a shim for it. I tried to do a quick search for the source of the error message but I couldn't find it. It's also possible that this is a problem with one of the dependencies used to interact with the biome.exe.

LucasOe commented 2 weeks ago

I just tried setting the path of LSP to the biome.exe without the shim and the issue persists:

"biome.lsp.bin": {
    "win32-x64": "C:\\Users\\lucas\\scoop\\apps\\biome\\current\\biome.exe"
},

Output Biome LSP (global session):

2024-10-10 11:59:42.304 [info] Cannot open shim file for read. Could not read shim file.

2024-10-10 11:59:42.306 [info] [Error - 11:59:42 AM] Biome language server closed 2024-10-10 11:59:42.307 [info] [Error - 11:59:42 AM] biome client: couldn't create connection to server. 2024-10-10 11:59:42.307 [info] Message: Pending response rejected since connection got disposed Code: -32097

The Output tab still says Could not read shim file., even though this biome.exe is not a shim. The binary I'm using is the biome-win32-x64.exe from https://github.com/biomejs/biome/releases. In other words: it looks like the issue I'm having has nothing to do with Scoop or shims, as manually downloading the binary produces the same error!

LucasOe commented 2 weeks ago

Here are the new steps to reproduce:

  1. Download biome-win32-x64.exefrom biomejs/biome/releases
  2. Add the binary to your PATH, or set biome.lsp.bin in settings.json
  3. Install the Biome Extension for VSCode and switch to the pre-release version
  4. Close VSCode
  5. Open single file in VSCode, or a directory if biome.requireConfigFile is set to false (https://github.com/biomejs/biome-vscode/issues/390)
  6. Observe error notifications and check the Output panel for logs

Sorry for the confusion about Scoop. The error message made me believe this was a problem with the way the executable is shimmed.