Skip to content

Nix incompatible with git relative worktrees #14987

@stessaris

Description

@stessaris

Describe the bug

The current version of Nix (2.33.0) is not compatible with git relative workspaces introduced in 2.48.0. This is likely due to libgit2 not supporting the extension.

I don't think there's much to do, other than waiting for libgit2 catching up with git stable versions, and recommend to avoid the feature. I just wanted to add the issue to warn anybody else stumbling into the issue, and how to revert to absolute worktrees as workaround.

Steps To Reproduce

Make sure you're using git version greater or equal than 2.48.0.

  1. Create a git repo with a nix configuration
    nix flake new --template 'templates#bash-hello' test
    git -C test init && git -C test add . && git -C test commit -m "Initial commit"
  2. Verify that's working as expected:
    git -C test config --local --list
    nix run ./test
  3. Add a relative worktree:
    git -C test worktree add --relative-paths -b dev ../test.worktrees/dev
  4. Now you get the error
    git -C test config --local --list
    nix run ./test
    The error should be something like
    error:
      … while fetching the input 'git+file:///.../test'
      error: opening Git repository "/.../test": unsupported extension name extensions.relativeworktrees
    
    Note the new line extensions.relativeworktrees=true in the local configuration.

Getting rid of relative worktree configuration will fix the problem:

git -C test.worktrees/dev worktree repair --no-relative-paths
git -C test config unset --local extensions.relativeworktrees
nix run ./test

Expected behavior

nix should work with features of the stable versions of git

Metadata

nix-env (Determinate Nix 3.15.1) 2.33.0

Additional context

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions