biomejs / biome-vscode

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

🐛 Biome not detected in dependencies #283

Closed tylerlaprade closed 2 weeks ago

tylerlaprade commented 1 month ago

VS Code version

1.91.1

Extension version

2.3.0

Biome version

1.8.3

Operating system

Description

I see this popup, and don't get any linting from Biome, even though I have Biome in my project's devDependencies in package.json

image

Steps to reproduce

  1. Add "@biomejs/biome": "1.8.3", to devDependencies
  2. Install the Biome extension
  3. Reload the window

Expected behavior

Biome should detect that it's installed from package.json

Does this issue occur when using the CLI directly?

Yes

Logs

No response

ematipico commented 1 month ago

Thank you @tylerlaprade for opening the issue. Would you mind sharing a reproduction?

tylerlaprade commented 1 month ago

@ematipico, once I clicked Download Biome, I'm not getting it anymore, but that is just a band-aid fix. I tried deleting all "Biome" files on my computer in order to repro, but it's still globally installed somewhere. (Not on the command line, so I can't which biome).

To repro, any node project should suffice with Biome in devDependencies.

ematipico commented 1 month ago

Sorry @tylerlaprade, but I use Biome myself in other Node.js. projects, and I don't experience this issue, it's possible that it's something related to your project or your machine. That's why we ask for a minimal, reproducible reproduction

tylerlaprade commented 1 month ago

Sure, makes sense. In that case, what's the best way for me to uninstall Biome from wherever that button put it? I can't find it in file search.

ematipico commented 1 month ago

@tylerlaprade There's a command palette for that Biome: clear versions cache

tylerlaprade commented 1 month ago

@ematipico, I still have this "bundled" thing showing after clearing versions cache. My teammate is also getting the constant popup warning as well.

image
nhedger commented 1 month ago

Ah, this might have been poor communication on my part. This command does not actually clear the downloaded versions, but we cache the request that retrieves the list of available versions from GitHub to avoid hitting the rate limit. This command is used to reset this cache.

To clear this "bundled" version, you need to delete the following folder manually:

~/Library/Application Support/Code/User/globalStorage/biomejs.biome/server

We'll make sure to add a command that does this in the next version.

nhedger commented 2 weeks ago

I'm closing this as I believe the latest nightly fixes this issue. Let me know if it's not the case.

tylerlaprade commented 4 days ago

Thanks @nhedger. I assume you meant pre-release, as "nightly" is deprecated.

image

After switching to pre-release, I have a different popup, but I'm still missing Biome. I expect to have it because it's in my package.json and I've run npm i. Could the problem be that it's a monorepo and package.json isn't in the root folder?

image
nhedger commented 3 days ago

Thanks @nhedger. I assume you meant pre-release, as "nightly" is deprecated. image After switching to pre-release, I have a different popup, but I'm still missing Biome. I expect to have it because it's in my package.json and I've run npm i. Could the problem be that it's a monorepo and package.json isn't in the root folder? image

Hey, sorry I sometimes use the terms interchangeably since we deprecated the actual nightly version, but you're correct I meant the pre-release.

As for the extension not detecting Biome, I believe it is indeed because you're in a monorepo. The extension will try to find Biome at in the Project, which happens to be the root of your workspace folder by default. You can explicitly declare projects with the biome.projects setting.

Try adding the following to your ${workspaceFolder}/.vscode/settings.json file:

{
    "biome.projects": [
        { "path": "/path/to/the/subfolder" }
    ]
}
tylerlaprade commented 3 days ago

@nhedger, hmm, that's still not working, both with and without a slash at the end of the path. I'm in a monorepo, but with only one relevant project - the back-end is in Python. So I have biome.jsonc in my workspace root, but package.json and node_modules/ are in the subfolder. I confirmed that node_modules/ contains @biomejs.

image image
nhedger commented 3 days ago

Would you mind providing a minimal reproduction repo? I'll have a look!

tylerlaprade commented 3 days ago

Sure! I was able to repro without a monorepo. https://github.com/tylerlaprade/biome_bug Steps:

  1. Open this project in a fresh VSCode install
  2. Run npm i to install Biome
  3. Developer: Reload Window to see the error trigger
nhedger commented 3 days ago

I can't seem to reproduce. The global session seems to error, and I'll have to investigate that, but the LSP session for the project at / seems to be created correctly.

Could I trouble you for a screen recording?

tylerlaprade commented 3 days ago

Sure, how's this: https://www.loom.com/share/708aae2faab4444b8a31caf6e0931ba3?sid=833839d4-f0d1-49f3-a8e7-6667ac0782f4

nhedger commented 3 days ago

Thanks, I think I found the issue.

When the extension boots, it creates a global LSP session and a project-specific LSP session. I believe the popup you see is triggered by the global LSP session starting because a global Biome cannot be found on your system. When you install Biome in your node_modules and restart VS Code, it again attempts to start the global session. When you dismiss the notification, it actually boots the project-specific LSP session (you can see Biome 1.8.3 in your status bar).

I initially intended for users to download Biome on the fly using the popup so that they could start the global LSP session. However, I'm realizing now that the intent may not be obvious.

In the meantime, clicking Yes in the popup to download Biome should solve the issue. This will download a biome binary used for the global LSP session and shouldn't prompt you anymore.

I'll have to think of a better way to signal users why they see this popup.

tylerlaprade commented 2 days ago

@nhedger, even though I see "Biome 1.8.3" in the status bar, the extension doesn't seem to be able to make use of it. I don't get formatting on save or any errors/warning squiggles in my code

Regarding clicking Yes for the global download, I don't want my local environment to ever use a different version that what I have in CI. That would cause me to not realize my PR will fail the build until I submit it.

nhedger commented 2 days ago

To be clear, the downloaded version would only be used with the global session which handles files that are not part of your project such as Untitled (unsaved) files.

tylerlaprade commented 2 days ago

Ah okay - in that case it seems like there's still a bug? The project one is not working on files that are part of my project.

tylerlaprade commented 2 days ago

Also, FWIW, I'm not seeing the Biome 1.8.3 anymore. This just spins forever.

image