尝试从/nix/store中删除一个包,现在系统出现错误,如何修复


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

我手动删除了一些文件,试图删除该包。然而,nixshell不再工作,并向我发出了上述消息。如何在nix中解决问题?我想完全删除程序包并重新安装。

此外,当我运行以下命令时:

~/sources/integration_test >>> nix-env -u python3.7-somepackagesomepackage-1.0.0
error: selector 'python3.7-somepackages-1.0.0' matches no derivations

尝试运行

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

来自手册页:

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.

注意我建议您自己使用man nix-store阅读手册页,以确保这是您在运行此程序之前想要的。

注意:2由于操作的性质,需要检查很多内容——此操作需要一段时间。对于我的11 GiB/nix/store,它运行了4m13秒。


附录将来,当您想手动从nix存储中删除包时,请使用

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

相反。

最新更新