biomejs / biome

A toolchain for web projects, aimed to provide functionalities to maintain them. Biome offers formatter and linter, usable via CLI and LSP.
https://biomejs.dev
Apache License 2.0
14.12k stars 432 forks source link

πŸ›(WinOS) `--config-path` causes "unexpected error" #3479

Open rivy opened 1 month ago

rivy commented 1 month ago

Environment information

CLI:
  Version:                      1.8.3
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           windows

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           unset
  JS_RUNTIME_NAME:              unset
  NODE_PACKAGE_MANAGER:         unset

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    true
  VCS disabled:                 false

Workspace:
  Open Documents:               0

What happened?

biome lint --config-path .\biome.jsonc panics, where otherwise, biome lint completes correctly.

❯ biome lint --config-path .\biome.jsonc
Biome encountered an unexpected error

This is a bug in Biome, not an error in your code, and we would appreciate it if you could report it to https://github.com/biomejs/biome/issues/ along with the following information to help us fixing the issue:

Source Location: C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\ignore-0.4.21\src\gitignore.rs:229:9
Thread Name: biome::worker_0
Message: path is expected to be under the root

Expected result

It should not panic.

Code of Conduct

Conaclos commented 1 month ago

@ematipico Are you able to reproduce this bug?

ematipico commented 1 month ago

The error comes from the ignore crate, so it's possible we are passing an incorrect path. However, we need a reproduction. This is an issue generated by the VCS integration

rivy commented 2 weeks ago

@ematipico , why are you closing this issue? It's a fundamental problem when running the application. πŸ˜•

ematipico commented 2 weeks ago

We requested a reproduction, but that was never provided. After so much inactivity, we close the issue.

rivy commented 2 weeks ago

I don’t understand. A reproduction was included in my initial post about the issue. It includes the simple WinOS command line which prompts the bug and the output (including the request to post it here to help you fix the issue).

Conaclos commented 2 weeks ago

I don’t understand. A reproduction was included in my initial post about the issue. It includes the simple WinOS command line which prompts the bug and the output (including the request to post it here to help you fix the issue).

Could you share the .gitignore in the directory where you executed Biome? Without it, I think we are not able to reproduce the error.

rivy commented 2 weeks ago

@Conaclos , happy to do so, and thanks for looking at this issue.

# git ignore config file
# v2024-04-30 [rivy]
# spell-checker:ignore () yarnrc (jargon) globstar (names) deno dlang (people) Roy Ivy III * rivy

# NOTE: Git GLOBSTAR syntax [see `git help gitignore`]
# * ref: [.gitignore] http://git-scm.com/docs/gitignore @@ http://archive.is/Rk6rO
# * ref: [Generate a 'gitignore'](https://gitignore.io) ; eg, <https://gitignore.io/api/node>

# build/dist artifacts
/build
/[._@#$]build
/dist
/target
# note: `git add --force dist && git commit -m 'change: add updated dist artifacts'` will still add any desired distribution artifacts
# note: `git status --ignored -- build dist target` will still show changes (for release testing)
# * project cache directories
/.*-cache
/zig-cache

# coverage data
/coverage
/[._@#$]coverage
/.nyc_output

# D (dlang)
# * dub
/.dub
# note: 'dub.selections.json' is a generated file, useful to applications (for reproducible builds) but not generally for libraries; use `git add --force ...` if needed
/dub.selections.json

# Deno
/deno.lock

# JS/TS
# * ignore JS import/package-related files
/node_modules
/package-lock.json
/yarn.lock
# * allow packaging of lock files into '.deps-lock'
!/.deps-lock/package-lock.json
!/.deps-lock/yarn.lock
# * ignore `yarn`-related files (allows use of "modern" v2+ `yarn`)
# - ref: <https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored> @@ <https://archive.is/Sc1Ab>
.pnp.*
/.yarn/*
!/.yarn/patches
!/.yarn/plugins
!/.yarn/releases
!/.yarn/sdks
!/.yarn/versions
# * use `.yarnrc.yml` for `yarn` config
/.yarnrc

# VSCode
# * ignore local-only VSCode artifacts
# - logs/settings
/.vscode/c_cpp_properties.json
/.vscode/makefile.extension.output
# - precompiled headers for IntelliSense ## spell-checker:ignore ipch
/.vscode/ipch/

## local-start
## local-end

Any use of --config-path causes the error (eg, biome lint --config-path .biome.lenient.jsonc, ...).

Let me know if there's anything else I can do to help track down the cause.

rivy commented 2 weeks ago

@Conaclos , notably:

1 - an empty or missing .gitignore avoids the error 2 - a .gitignore with only comments avoids the error 3 - a .gitignore with any actual "ignore" (non-commentary) content => ERROR

I hope that's helpful.

Conaclos commented 2 weeks ago

Unfortunately I cannot reproduce the issue.

Here is my attempt:

❯ git init

❯ npm init --yes

❯ npm i -D @biomejs/biome

❯ tree 
β”œβ”€β”€ biome.jsonc
β”œβ”€β”€ package.json
β”œβ”€β”€ src
β”‚Β Β  └── index.js

❯ cat biome.jsonc
{
  "vcs": {
    "enabled": true,
    "clientKind": "git",
    "useIgnoreFile": true
  }
}

❯ npx biome lint --config-path ./biome.jsonc 
Checked 3 files in 909Β΅s. No fixes applied.

Note: I am on Linux.

rivy commented 2 weeks ago

@Conaclos ,

Yes, it looks like a WinOS-specific problem. Using WSL with the exact same project files of my prior example, there is no error.

rivy commented 2 weeks ago

Here's a minimal reproduction (file repo at https://github.com/rivy-fix/biome-config-bug).

> dir
 Volume in drive C is Local Disk
 Volume Serial Number is 1C33-48C1

 Directory of C:\Users\Roy\AARK\Projects\js\t-biome\repo

2024-08-29  20:22    <DIR>          .
2024-08-29  20:22    <DIR>          ..
2024-08-29  20:24    <DIR>          .git
2024-08-29  20:21                 3 .gitignore
2024-08-29  20:19               137 biome.json
2024-08-29  20:09               329 package.json
               3 File(s)            469 bytes
               3 Dir(s)  369,052,930,048 bytes free
> cat .gitignore
FOO
> cat biome.json
{
        "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
        "vcs": { "clientKind": "git", "enabled": true, "useIgnoreFile": true }
}
> cat package.json
{
  "name": "repo",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "Roy Ivy III <rivy.dev@gmail.com> (https://rivy.dev/)",
  "license": "MIT",
  "description": "",
  "devDependencies": {
    "@biomejs/biome": "^1.8.3"
  }
}
> npx biome lint
Checked 2 files in 1988Β΅s. No fixes applied.
> npx biome lint --config-path biome.json
Biome encountered an unexpected error

This is a bug in Biome, not an error in your code, and we would appreciate it if you could report it to https://github.com/biomejs/biome/issues/ along with the following information to help us fixing the issue:

Source Location: C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\ignore-0.4.21\src\gitignore.rs:229:9
Thread Name: biome::worker_0
Message: path is expected to be under the root
> wsl
...
$ npx biome lint
Checked 2 files in 2ms. No fixes applied.
$ npx biome lint --config-path biome.json
Checked 2 files in 2ms. No fixes applied.
ematipico commented 2 weeks ago

Thank you. That's what I meant with providing a reproduction. Providing only the commands isn't enough.

rivy commented 2 weeks ago

Sorry, your prior message seemed internal, not directed at me for additional information. I'm happy to help narrow down the issue. Just ask if you need anything else.