Skip to content

Formatter does not work in a git worktree #373

@kuruczgy

Description

@kuruczgy

Describe the bug

Running nix fmt (set up as recommended in the README) fails with

Error: failed to load config: failed to determine tree root: failed to find tree-root based on tree-root-file: could not find [.git/config] in /path/to/your/worktree

To Reproduce

Steps to reproduce the behavior:

  1. Create a git worktree using git worktree add
  2. Try to run nix fmt in the worktree.

Expected behavior

Formats as normal.

System information

treefmt-nix version: a05be41
nixpkgs version: 56b033fe4f9da755b1872466f24b32df7cfc229e

nix-shell -p nix-info --run "nix-info -m":

 - system: `"aarch64-linux"`
 - host os: `Linux 6.16.0-rc3, NixOS, 25.11 (Xantusia), 25.11.20250615.cbfb263`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Lix, like Nix) 2.91.1
System type: aarch64-linux
Additional system types: 
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /home/user/.config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/user/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/user/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/user/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/g9clkwljsncp6fadzc105ay78b7l6mg2-lix-2.91.1/share`
 - nixpkgs: `/nix/store/nki040zkkasz5mnd7c6jv0gn3sipmc30-source`

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions