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

Failed to run biome (zed 0.157.5) #52

Open
cherewaty opened this issue Oct 17, 2024 · 6 comments
Open

Failed to run biome (zed 0.157.5) #52

cherewaty opened this issue Oct 17, 2024 · 6 comments

Comments

@cherewaty
Copy link

Getting a "Failed to run biome. Click to show error." Was working until the last few days. I'm assuming it was a zed update.

The error:

Language server error: biome

failed to spawn command. path: "/Users/me/project/node_modules/@biomejs/biome/bin/biome", working directory: "/Users/me/project", args: ["lsp-proxy", "--config-path", "biome.json"]
-- stderr--

My biome.json is at the root of the workspace.

The relevant parts of my zed settings, with new additions from https://biomejs.dev/reference/zed/:

{
	"language_servers": ["biome", "!prettier", "!eslint"],
	"lsp": {
		"biome": {
			"settings": {
				"require_config_file": true
			}
		}
	},
	"formatter": {
		"language_server": {
			"name": "biome"
		}
	},
	"code_actions_on_format": {
		"source.fixAll.biome": true,
		"source.organizeImports.biome": true
	},
}

zed 0.157.5, macOS 15.0.1

@luckydye
Copy link
Collaborator

I can't reproduce this issue, can you provide more information?
I am on latest versions.

Also check if /Users/me/project/node_modules/@biomejs/biome/bin/biome actually exists.

@michalmo
Copy link

I recently started having the same issue.

In my case project dependencies are managed by yarn (pnp) so node_modules is largely empty. I do have the yarn sdks installed (https://zed.dev/docs/languages/yarn).

I am able to make it work by forcing the path:

{
  "lsp": {
    "biome": {
      "binary": {
        "path": ".yarn/unplugged/@biomejs-cli-darwin-arm64-npm-1.9.3-0fbea5824d/node_modules/@biomejs/cli-darwin-arm64/biome",
        "arguments": [
          "lsp-proxy"
        ]
      }
    }
  }
}

However this isn't ideal since it will need to be updated with every version update.
Also the path returned by yarn bin biome (.yarn/unplugged/@biomejs-biome-npm-1.9.3-a7b2320732/node_modules/@biomejs/biome/bin/biome) doesn't work, it needs to be the path to the platform specific package.

@Marcisbee
Copy link

I get the same error. The problem here is something else in my case for example. Clean install with yarn v4.0.2 doesn't make this bin file executable.

Error:

Language server error: biome

failed to spawn command. path: "/private/var/www/project/node_modules/@biomejs/biome/bin/biome", working directory: "/private/var/www/project", args: ["lsp-proxy", "--config-path", "biome.json"]
-- stderr--

Error from sh:

❯ /private/var/www/project/node_modules/@biomejs/biome/bin/biome
zsh: permission denied: /private/var/www/project/node_modules/@biomejs/biome/bin/biome

When I manually update permissions, extension then works in zed. When I run yarn install again, it changes permissions once more and get the same error as before.

Issue is no longer present if I upgrade to latest yarn v4.5.1. Hope this helps someone.

@chungweileong94
Copy link
Contributor

chungweileong94 commented Nov 26, 2024

Currently, the extension will only try to use the LSP bin from node_modules/@biomejs/biome/bin/biome

if self.worktree_biome_exists(worktree) {

There was a limitation in Zed at the time, where we were unable to check if the LSP bin exists in node_modules, so the workaround at the time was to check if Biome is listed as part of the dependencies, then naively access the Biome LSP from node_modules, #9 (comment). So I'm not sure if the current Zed version still has issues with looking up the LSP bin.

Which means that the yarn pnp is not supported OOB, so the workaround is to define the Biome LSP bin as @michalmo mentioned above.

@GoldStrikeArch
Copy link

GoldStrikeArch commented Dec 18, 2024

I also have this issue after recent zed update (no config changes).
The current fix for me is this (I am on Mac M1 15.2) and this is only for formatting and lint fixes on save (I still don't have lsp support):

  1. brew install biome
  2. inside .zed/settings.json
  "formatter": {
    "external": {
      "command": "biome",
      "arguments": ["check", "--fix", "--stdin-file-path", "{buffer_path}"]
    }
  },

@samhh
Copy link

samhh commented Dec 19, 2024

I had this issue for a little while and it resolved itself, but then the formatter stopped respecting my project config. Here's what I'm using now that works in a pnpm repo:

{
  "lsp": {
    "biome": {
      "binary": {
        "path": "pnpm",
        "arguments": ["exec", "biome", "lsp-proxy"]
      }
    }
  },
  "formatter": {
    "external": {
      "command": "pnpm",
      "arguments": [
        "exec",
        "biome",
        "format",
        "--write",
        "--stdin-file-path",
        "{buffer_path}"
      ]
    }
  }
}

The LSP part may not be necessary but I prefer to ensure I'm using the same binary as there can be subtle differences across versions.

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

No branches or pull requests

7 participants