Skip to content

git 2.35.2 breaks nixos-rebuild with flake repo owned by non-root user #169193

@NickCao

Description

@NickCao

Describe the bug

After upgrading to git 2.35.2 (which is the version currently in nixos-unstable-small), running sudo nixos-rebuild switch with a flake repo owned by non-root user would result in a cryptic error message saying

warning: Not a git repository. Use --no-index to compare two paths outside a working tree
usage: git diff --no-index [<options>] <path> <path>
...... (the full git diff help)
error: program 'git' failed with exit code 129
(use '--show-trace' to show detailed location information)

The underlying reason is that due to the fix for CVE-2022-24765, git now effectively treats any directory not owned by the calling user as not a git repo. A temporary workaround would be to add the repo to safe.directory entry of the root user's git config. A possible long term fix is to only use sudo or others means for privilege elevation when absolutely required in nixos-rebuild.

Notify maintainers

@Profpatsch

Metadata

 - system: `"x86_64-linux"`
 - host os: `Linux 5.17.3, NixOS, 22.05 (Quokka), 22.05.20220418.f26866c`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.8.0pre20220411_f7276bc`
 - nixpkgs: `/nix/store/xy6wkddgna3rsmqkb53120x8lpf1pbvr-source`

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions