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

🐛 Unable to get Biome running in a subfolder of a single-folder workspace #403

Closed
1 of 3 tasks
flekschas opened this issue Oct 17, 2024 · 13 comments
Closed
1 of 3 tasks
Labels
Prerelease Triage Waiting for response Waiting for a response from the author of the issue

Comments

@flekschas
Copy link

flekschas commented Oct 17, 2024

VS Code version

1.93.1

Extension version

v2024.10.131712

Biome version

1.9.4

Operating system

  • Windows
  • macOS
  • Linux

Description

I'm trying to get the Biome VSCode extension running to lint+format JS code that lives in a subfolder of my workspace.

My setup is fairly simply:

- .vscode
   - settings.json
- js
   - src
      - index.js (etc.)
   - biome.json
- pypackage

My .vscode/settings.json is

{
  "biome.enabled": true,
  "biome.lsp.trace.server": "verbose",
  "biome.projects": [
    {
      "path": "js"
    }
  ]
}

I see that the extension is loaded when looking at the Output panel:

2024-10-17 16:33:02.458 [info] Biome extension 2024.10.131712 activated
2024-10-17 16:33:02.558 [error] Could not find the Biome binary
2024-10-17 16:33:02.575 [info] Using previously downloaded version 1.9.3: /Users/Me/Library/Application Support/Cursor/User/globalStorage/biomejs.biome/global-bin/biome
2024-10-17 16:33:02.576 [debug] Found downloaded Biome binary
	path=/Users/Me/Library/Application Support/Cursor/User/globalStorage/biomejs.biome/global-bin/biome
	strategy=Download Biome
2024-10-17 16:33:02.586 [debug] A Biome binary for the same version 1.9.3 already exists in the temporary location.
	original=/Users/Me/Library/Application Support/Cursor/User/globalStorage/biomejs.biome/global-bin/biome
	temporary=/Users/Me/Library/Application Support/Cursor/User/globalStorage/biomejs.biome/tmp-bin/biome-1.9.3
2024-10-17 16:33:02.586 [debug] Ensure binary is executable
	binary=/Users/Me/Library/Application Support/Cursor/User/globalStorage/biomejs.biome/global-bin/biome
	before=is executable: true
	after=is executable: true
2024-10-17 16:33:02.801 [error] Failed to start Biome extension
2024-10-17 16:33:02.801 [info] Biome extension started
2024-10-17 16:33:02.802 [info] User-facing commands registered
2024-10-17 16:33:02.802 [info] Started listening for lockfile changes
2024-10-17 16:33:02.802 [info] Started listening for configuration changes
2024-10-17 16:33:02.802 [info] Started listening for active text editor changes

Apart from that, nothing else is logged, even after I change some files to JS files under js/src.

Am I missing anything? Should I be concerned about the initial fail to start biome and then the info output saying the extension started?

Steps to reproduce

Create an environment as outlined in Description, install VSCode, install the extension, open a JS file under js/src and add an unused variable, and finally notice how no hints are shown in the code panel.

Expected behavior

See Biome hints in the code editor

Does this issue occur when using the CLI directly?

No

Link to a minimal reproduction

https://github.com/flekschas/biome-issue

Logs

No response

@nhedger
Copy link
Member

nhedger commented Oct 18, 2024

Hey, thanks for reporting. Would you mind creating a minimal reproduction repo using npm create @biomejs/biome-reproduction

@flekschas
Copy link
Author

flekschas commented Oct 20, 2024

Thanks for getting back quickly and apologies for my late response. I've create a minimal reproducing repo at https://github.com/flekschas/biome-issue.

Screen.Recording.2024-10-20.at.11.33.23.AM.mp4

I wonder if my configuration is incorrect or if this kind of setup is just not supported by Biome. I hope it's the former because you guys did an absolutely fantastic job with Biome 👏 and I would not want to go back to ESLint + Prettier.

@nhedger
Copy link
Member

nhedger commented Nov 30, 2024

Sorry for the time it took to follow up here.

I'm assuming you're expecting Biome to warn about noUnusedVariable, but this won't be reported here because you're using a constant (const).

I've opened your repo, and Biome started correctly for your project, as seen in the following screencast.

Screen.Recording.2024-11-30.at.16.13.47.mov

@nhedger nhedger added the Waiting for response Waiting for a response from the author of the issue label Nov 30, 2024
@flekschas
Copy link
Author

Apologies, this was my mistake. Even if I change const to let, I don't get the Biome extension working in VSCode. It runs fine in Sublime Text but there's no pop up in VSCode.

biome.mp4

Any ideas what the issue might be? I wonder if there's an issue with the biome binary. For a few seconds I saw the following popup but it went away on it's own:

Screenshot 2024-11-30 at 11 57 41 AM

When I set "biome.lsp.bin": null then Biome throws [error] Could not find the Biome binary even though I have the binary located at js/node_modules/.bin/biome

@ematipico
Copy link
Member

When I set "biome.lsp.bin": null

You shouldn't. You should remove that option. When you set it, the extension tries to use the value that you set. Setting null is incorrect. You need to remove it.

@flekschas
Copy link
Author

flekschas commented Nov 30, 2024

Sure, I only tested this as the popup open. In the recorded video I'm not using the setting. So somehow, VSCode isn't able to resolve the local biome binary and is looking for a global one. Is that expected? I was under the impression that adding biome as a dependency ensures that the extension is using the local biome binary (https://biomejs.dev/reference/vscode/#biome-resolution). But somehow it seems like it's not.

@nhedger
Copy link
Member

nhedger commented Nov 30, 2024

Sure, I only tested this as the popup open. In the recorded video I'm not using the setting. So somehow, VSCode isn't able to resolve the local biome binary and is looking for a global one. Is that expected? I was under the impression that adding biome as a dependency ensures that the extension is using the local biome binary (https://biomejs.dev/reference/vscode/#biome-resolution). But somehow it seems like it's not.

This is indeed the expected behavior.

Could you set your logging level to Debug using the Developer: Set log level... command and reload the window? This should print debug logs that will tell us a bit more about how the resolution goes.

@flekschas
Copy link
Author

The debug logs are:

2024-11-30 20:06:59.465 [info] Biome extension 2024.11.301111 activated
2024-11-30 20:06:59.465 [debug] Trying to find Biome binary in VS Code settings
	bin=
2024-11-30 20:06:59.465 [debug] Trying to find Biome binary in Node Modules
	path=file:///Users/Fritz/Code/biome-issue/js
2024-11-30 20:06:59.465 [debug] Trying to find Biome binary in Yarn Plug'n'Play
	path=file:///Users/Fritz/Code/biome-issue/js
2024-11-30 20:06:59.487 [debug] Trying to find Biome binary in PATH environment variable
2024-11-30 20:06:59.567 [debug] Could not find Biome locally using any of the strategies.
2024-11-30 20:06:59.567 [error] Could not find the Biome binary
2024-11-30 20:06:59.567 [error] Failed to create session for project.
	project=/Users/Fritz/Code/biome-issue/js
2024-11-30 20:06:59.568 [debug] Trying to find Biome binary in VS Code settings
	bin=
2024-11-30 20:06:59.568 [debug] Trying to find Biome binary in PATH environment variable
2024-11-30 20:06:59.586 [debug] Trying to find downloaded Biome binary
2024-11-30 20:06:59.586 [debug] Getting downloaded version

I've played around with the biome.lsp.bin setting of .vscode/setting.json but no matter what I set there I always end up with

2024-11-30 20:14:02.661 [info] Biome extension 2024.11.301111 activated
2024-11-30 20:14:02.661 [debug] Trying to find Biome binary in VS Code settings
	bin=js/node_modules/@biomejs/biome/bin/biome
2024-11-30 20:14:02.687 [debug] Trying to find Biome binary in Node Modules
	path=file:///Users/Fritz/Code/biome-issue/js
2024-11-30 20:14:02.687 [debug] Trying to find Biome binary in Yarn Plug'n'Play
	path=file:///Users/Fritz/Code/biome-issue/js
2024-11-30 20:14:02.705 [debug] Trying to find Biome binary in PATH environment variable
2024-11-30 20:14:02.777 [debug] Could not find Biome locally using any of the strategies.
2024-11-30 20:14:02.777 [error] Could not find the Biome binary

I've tried the following settings:

  • js/node_modules/.bin
  • js/node_modules/.bin/
  • js/node_modules/.bin/biome
  • js/node_modules/@biomejs/biome
  • js/node_modules/@biomejs/biome/bin
  • js/node_modules/@biomejs/biome/bin/
  • js/node_modules/@biomejs/biome/bin/biome

@nhedger
Copy link
Member

nhedger commented Dec 1, 2024

biome.lsp.bin is meant to contain the path (relative or absolute) to the actual biome binary, not the wrapper shell script that you're referencing here.

Depending on your system, this would be something like js/node_modules/@biomejs/cli-darwin-x64/biome.

However, in this case, you're actually better off letting the extension figure out automatically this path.

@flekschas
Copy link
Author

Sure but the extension doesn't seem to find the binary in the js or am I misreading the logs?

@nhedger
Copy link
Member

nhedger commented Dec 1, 2024

In my case, there was no issue starting the LSP session.

Did you reload the window after having installed your node modules ?

@flekschas
Copy link
Author

flekschas commented Dec 2, 2024

Yes I did.

So I figured out what the issue is: I never properly migrated my machine setup to arm64 after I got an Apple silicon macbook. This caused the x64 version to be installed because the node version was x64. I suspect that because VSCode was on arm64 it didn't recognize the locally installed x64 binary.

After migrating by bash version + brew + nvm, the VSCode extension successfully finds the binary.

For anyone else who might run into this issue, here's the chain of things I did to fix the problem:

  1. Change your shell in case that's still on i386. See https://apple.stackexchange.com/a/458142
  2. [Optional] Upgrade/reinstall homebrew. See https://apple.stackexchange.com/questions/410825/apple-silicon-port-all-homebrew-packages-under-usr-local-opt-to-opt-homebrew
  3. Potentially remove the current node binary using nvm uninstall and reinstall it.
  4. Check that node is truly running on arm64 via node -p 'process.arch'
  5. Remove node_modules and reinstall all packages via npm install
  6. Reload VSCode's window

I know this is a very esoteric error but it would be nice if the Biome extension was somehow notifying the user about the issue similar to how npm notifies the user when they try to install a binary that doesn't match their shell. But I also know that this is probably very low of a priority :)

Thanks for your help guys and keep up the good work with Biome!

@nhedger
Copy link
Member

nhedger commented Dec 2, 2024

Thanks for the deets, @flekschas!

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

No branches or pull requests

3 participants