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

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

Closed
1 of 3 tasks
LucasOe opened this issue Oct 9, 2024 · 6 comments
Closed
1 of 3 tasks
Labels
Prerelease Waiting for response Waiting for a response from the author of the issue Windows

Comments

@LucasOe
Copy link

LucasOe commented Oct 9, 2024

VS Code version

1.94.1

Extension version

2024.10.40751 (pre-release)

Biome version

1.9.3

Operating system

  • Windows
  • macOS
  • Linux

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 (🐛 biome.requireConfigFile Ignored When Opening Single File in VSCode #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
@LucasOe LucasOe added the Triage label Oct 9, 2024
@LucasOe LucasOe changed the title 🐛 "Cannot open shim file for read." when Biome is installed through Scoop 🐛 "Cannot open shim file for read." when Biome is installed through Scoop / shimmed Oct 9, 2024
@nhedger
Copy link
Member

nhedger commented Oct 10, 2024

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
Copy link
Author

LucasOe commented Oct 10, 2024

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
Copy link
Author

LucasOe commented Oct 10, 2024

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 LucasOe changed the title 🐛 "Cannot open shim file for read." when Biome is installed through Scoop / shimmed 🐛 "Cannot open shim file for read." when using biome-win32-x64.exe Oct 10, 2024
@LucasOe
Copy link
Author

LucasOe commented Oct 10, 2024

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 (🐛 biome.requireConfigFile Ignored When Opening Single File in VSCode #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.

@nhedger
Copy link
Member

nhedger commented Feb 7, 2025

I'm able to reproduce the issue in a VM, and the issue is a combination of how Scoop and the extension work.

  • When the extension boots, it looks for biome.exe, which it finds in your scoop directory (using PATH based detection).
  • The first time it finds it, it copies the biome.exe file into a temporary directory that the extension manages. We do this to to let you update your binary which would be locked if we ran biome directly from it.
  • When the extension attempts to start Biome from the copied biome.exe file, it fails because this binary isn't the original biome binary, but a modified binary that expects the biome.shim file to be present, which it isn't because we haven't copied the file to the temporary directory.
  • Later, when you installed Biome directly from our releases, and put it in your PATH, when the extension started, it didn't copy biome.exe to the temporary directory, because the file was already present (the one provided by scoop), so it attempted again to start the server from that broken binary.

What you can do:

  1. Close all VS Code instances
  2. Clean up the broken binary by deleting the following folder: C:\Users\username\AppData\Roaming\Code\User\globalStorage\biomejs.biome
  3. Either use the official Biome release installed in your PATH, or install it as part of your node_modules

@nhedger nhedger added Waiting for response Waiting for a response from the author of the issue and removed Triage labels Feb 7, 2025
@nhedger nhedger closed this as completed Feb 7, 2025
@LucasOe
Copy link
Author

LucasOe commented Feb 8, 2025

@nhedger I didn't expect the extension to copy the binary, that definitely explains the behavior I experienced and why the problem remained afterward. I didn't think you'd find the cause, given my long and unstructured write-up. Thank you for your research!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Prerelease Waiting for response Waiting for a response from the author of the issue Windows
Projects
None yet
Development

No branches or pull requests

2 participants