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

🐛 Biome not detected in dependencies #283

Closed
1 of 3 tasks
tylerlaprade opened this issue Jul 25, 2024 · 30 comments
Closed
1 of 3 tasks

🐛 Biome not detected in dependencies #283

tylerlaprade opened this issue Jul 25, 2024 · 30 comments
Labels
Needs reproduction Needs a reproduction Triage

Comments

@tylerlaprade
Copy link
Contributor

VS Code version

1.91.1

Extension version

2.3.0

Biome version

1.8.3

Operating system

  • Windows
  • macOS
  • Linux

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 ematipico added the Needs reproduction Needs a reproduction label Jul 25, 2024
@ematipico
Copy link
Member

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

@tylerlaprade
Copy link
Contributor Author

@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
Copy link
Member

ematipico commented Jul 25, 2024

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

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

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

@tylerlaprade
Copy link
Contributor Author

@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
Copy link
Member

nhedger commented Jul 30, 2024

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

nhedger commented Aug 22, 2024

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

@nhedger nhedger closed this as completed Aug 22, 2024
@tylerlaprade
Copy link
Contributor Author

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

nhedger commented Sep 4, 2024

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

@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
Copy link
Member

nhedger commented Sep 4, 2024

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

@tylerlaprade
Copy link
Contributor Author

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

nhedger commented Sep 4, 2024

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

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

@nhedger
Copy link
Member

nhedger commented Sep 5, 2024

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

@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
Copy link
Member

nhedger commented Sep 5, 2024

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

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

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

@321ckatz123
Copy link

@nhedger just for clarity sake, can this be re-opened as it was closed due to belief it was fixed in the pre-release, which doesn't appear to be true?

@nhedger
Copy link
Member

nhedger commented Sep 23, 2024

@nhedger just for clarity sake, can this be re-opened as it was closed due to belief it was fixed in the pre-release, which doesn't appear to be true?

Would you mind creating a new issue with your own reproduction inside, please?

@tylerlaprade
Copy link
Contributor Author

FWIW @321ckatz123 works with me so we both have the same repro :)

@tylerlaprade
Copy link
Contributor Author

@nhedger, I added the following line to my settings.json and now I get the original (but still buggy) behavior I first reported.
"biome.projects": [{"path": "paqarina"}]
I now have the correct Biome version displayed in the bottom right, but I am still unable to format or lint any files in VSCode, regardless of whether they're in the project or not. I also get this popup for every single file I open (even though those files are in the paqarina/ folder), which is quite noisy.
image
image

@nhedger
Copy link
Member

nhedger commented Sep 24, 2024

Happy to try and reproduce it if you can provide a minimal reproduction repo with these settings.

@tylerlaprade
Copy link
Contributor Author

Sure thing - here it is @nhedger
https://github.com/tylerlaprade/biome_bug

@alepell
Copy link

alepell commented Jan 2, 2025

hello guys, any1 got a fix for this?

@cimchd
Copy link

cimchd commented Feb 2, 2025

Same problem in a yarn 3.2.2 monorepo.
In the root package.json is a devDependency for @biomejs/biome v1.9.4

But I always get the message Could not find Biome in your dependencies. Either add the @biomejs/biome package to your dependencies, or download the Biome binary.

Formatter does not work after I click OK. At the moment only the biome cli is working for me.

I am confused. Is this a bug?, Did I miss something? Or will this only work after biomejs/biome#2228 is implemented?

@tjb1019
Copy link

tjb1019 commented Feb 25, 2025

I ran into the same issue and was able to get it working by turning off PATH search and manually pointing to the biome bin in node_modules.

.vscode/settings.json

{
    "biome.searchInPath": false,
    "biome.lspBin": "client/node_modules/@biomejs/cli-darwin-x64/biome",
}

@tylerlaprade
Copy link
Contributor Author

@tjb1019 , does that fix it even for files outside the workspace?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs reproduction Needs a reproduction Triage
Projects
None yet
Development

No branches or pull requests

7 participants