5
error: opening file '/nix/store/4h464mkqfipf04jgz4jp3bx56sdn6av0-python3.7-somepackage-1.0.0.drv': No such file or directory

I manually deleted some files in attempt to remove the package. However nix-shell no longer works and gives me the above message. How do I fix the problem in nix? I want to completely remove the package and reinstall it.

Additionally when I run the command below:

~/sources/integration_test >>> nix-env -u python3.7-somepackagesomepackage-1.0.0
error: selector 'python3.7-somepackages-1.0.0' matches no derivations
Brian Yeh
  • 3,119
  • 3
  • 26
  • 40

1 Answers1

9

Try running

 nix-store --verify --check-contents --repair

From the manpages:

OPERATION --VERIFY
   Synopsis
       nix-store --verify [--check-contents] [--repair]

   Description
       The operation --verify verifies the internal consistency of the Nix database, and the
       consistency between the Nix database and the Nix store. Any inconsistencies
       encountered are automatically repaired. Inconsistencies are generally the result of
       the Nix store or database being modified by non-Nix tools, or of bugs in Nix itself.

       This operation has the following options:

       --check-contents
           Checks that the contents of every valid store path has not been altered by
           computing a SHA-256 hash of the contents and comparing it with the hash stored in
           the Nix database at build time. Paths that have been modified are printed out.
           For large stores, --check-contents is obviously quite slow.

       --repair
           If any valid path is missing from the store, or (if --check-contents is given)
           the contents of a valid path has been modified, then try to repair the path by
           redownloading it. See nix-store --repair-path for details.

NB. I recommend reading the manpages yourself with man nix-store to ensure this is what you want before running this.

NB.2 Due to the nature of the operations, a lot has to be checked―this operation will take a while. For my 11 GiB /nix/store, this ran for 4m13s.


Addendum. In future, when you want to delete a package from the nix store manually, use

nix-store --delete /nix/store/[what you want to delete]

instead.

CH.
  • 556
  • 1
  • 5
  • 16