biomejs / biome

A toolchain for web projects, aimed to provide functionalities to maintain them. Biome offers formatter and linter, usable via CLI and LSP.

Home Page:https://biomejs.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Path with brackets in it causes `internalError/io` on Windows environment

mbacalan opened this issue · comments

Environment information

CLI:
  Version:                      1.8.1
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           windows

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         unset
  JS_RUNTIME_VERSION:           "v20.13.1"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "yarn/1.22.19"

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

Workspace:
  Open Documents:               0

Done in 0.56s.

What happened?

We're running biome as part of a pre-commit hook via lefthook. Trying to commit code with offending formatting results in error when the file has brackets in its path, but only on Windows:

'path/to/[parameterized]/file.tsx' internalError/io  INTERNAL  ━━━━━━━━━━

  × The system cannot find the path specified. (os error 3)
  
  ! This diagnostic was derived from an internal Biome error. Potential bug, please report it if necessary.
  

┃  check ❯ 

yarn run v1.22.19
$ C:\Users\foo\bar\node_modules\.bin\biome format --write --no-errors-on-unmatched --files-ignore-unknown=true 'path/to/[parameterized]/file.tsx'
Formatted 0 files in 117µs. No fixes needed.
Done in 3.49s.

We use brackets as part of a file-system based routing for our web application, where brackets indicate a dynamic route.

This issue does not occur in a WSL / Unix environment. Our team works across different OS' so this enables colleagues using Windows to push offending code.

Expected result

It should find and format the file.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

It appears that running C:\Users\foo\bar\node_modules\.bin\biome format --write --no-errors-on-unmatched --files-ignore-unknown=true 'path/to/[parameterized]/file.tsx' directly in terminal works as expected, even on Windows.

I'm not sure then if this is caused by Biome running as part of a Git hook or if its something to do with Lefthook.

Hi, could you please share a repo for us to reproduce the issue more easily?

Hi, could you please share a repo for us to reproduce the issue more easily?

Yes, there you go: https://github.com/mbacalan/biome-brackets-bug

I'm able to reproduce this on a windows machine, thanks for providing the repro!

I think this is a lefthook bug or misuse, I added a debug output to print the file path Biome received:

  • On a Linux machine or WSL, the path passed to the Biome CLI is "src/orders/[order-id]/index.tsx":
    image

  • On a Windows machine, the path passed to the Biome CLI is "\'src/orders/[order-id]/index.tsx\'":
    image

I'm afraid there isn't much Biome can do. Maybe you should create an issue there or try another tool.

Thanks for looking into this! I'll create a bug report for Lefthook.