Skip to content

Reviewing python PRs is broken when nixpkgs-review is made available via direnv #601

@Stebalien

Description

@Stebalien

The issue happens when nixpkgs-review (or any python package) is installed in the current shell via direnv. E.g., echo "use flake" > .envrc in the nixpkgs repo.

Here's what I think is happening:

  1. Direnv sets the PYTHONPATH when it makes nixkgs-review available in the current shell.
  2. nixpkgs-review pr #SOME_PYTHON_PR sets-up a nix-shell with a different PYTHONPATH (one that contains the python package to review).
  3. nixpkgs-review changes directory to ~/.cache/nixpkgs-review/... (at some point).
  4. nixpkgs-review opens a nix shell.
  5. The nix shell displays a prompt which runs the direnv hook.
  6. The direnv hook notices that the current directory doesn't match DIRENV_DIR, so it unloads the environment, unsetting PYTHONPATH.

It's possible to work around this by setting programs.direnv.loadInNixShell to false, but that's not the default behavior and debugging this is non-trivial.

IMO, the right way to fix this is for nixpkgs-review to clean its environment before and change to the ~/.cache directory entering the nix shell.

It would also be possible to fix this in direnv by checking if we're in a nixpkgs-review session here, but that won't help anyone using direnv via other means.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions