Error: this derivation has bad 'meta.outputsToInstall'


I’m using single-user Nix on Debian, and I recently started getting this error message when (un)installing packages. It first happened, I think, when I tried upgrading a package with nix-env -u --always <pkg>, and since then it happened without using --always.

I just tried --always because the manpage said (from my understanding) that it would install the latest package from the channel, even if that version was reported as being the same, and I assumed (apparently wrongly) that this would be safe.

Anyway, any ideas how to fix this?


Imperative package management with nix-env is currently based on package names (the name attribute returned by calling builtins.parseDrvName on the value of name attribute) by default. This means that when you try to update, Nix will scan the package set for a package with the same name as the «pkg»/each package you have installed (see the list with nix-env -q).

The issue with package names is that Nix needs to scan all packages in the set to find a match, making nix-env -u slow. Additionally, package names can be ambiguous.

Generally, I would recommend to use attribute paths to install (nix-env -iA «attrPath») and update (nix-env -uA «attrPath») individual packages as they fix both aforementioned issues. Unfortunately, nix-env does not record the attribute paths so updating all packages with nix-env -u will fall back to package name-based matching.

For that reason, I would recommend avoiding imperative package management in favour of declarative one. Either with nix-env, or using home-manager. See also Declarative package management for normal users - #2 by Mic92.

As for the error itself, could you share what package name are you trying to update and what Nixgkgs revision your channel points to?

Thanks for you detailed reply! I’ll read those links later, but the chapter you sent from the nix-env docs seems to be just the right thing for my needs (I didn’t know how to do this yet).

I get this error with at least gimp and kiwix:

$ nix-env -uA nixpkgs.kiwix
upgrading 'kiwix-2.0.5' to 'kiwix-2.2.1'
error: this derivation has bad 'meta.outputsToInstall'
$ nix-env -uA nixpkgs.gimp
upgrading 'gimp-2.10.30' to 'gimp-2.10.32'
error: this derivation has bad 'meta.outputsToInstall'
$ nix-channel --list
$ nix-instantiate --eval -E '(import <nixpkgs> {}).lib.version'

I read this last command from the manpage but don’t know if it’s the right one…

That is weird. I am unable to reproduce on 0c4852c7bc4 with Nix 2.9.1. What Nix version do you have and did you use Debian nix package or the Nix installer?

Looking at the relevant Nix source code, you could try installing nixpkgs.gimp.out to try the other branch:

Or you can try nix-channel --update in case it was temporary issue.

I’m also using Nix 2.9.1, and I did use the Nix installer. Running nix-env -iA nixpkgs.gimp.out gives the same error still, and the channel should be up-to-date already. Plus, this has been happening for a few weeks (since about the time I first used --always). Decided to wait so long before writing the post in case it was something solvable by nix-channel --update, as you suggested.

I think I may have just solved it…

I saved the list of installed packages (nix-env -q), switched to a pretty old environment generation (from like 1 month ago; nix-env --list-generations & nix-env --switch-generation $gen), ran nix-channel --update and nix-env -u, uninstalled the packages I no longer needed, and installed the packages I saved at the start. Both gimp and kiwix installed with no errors.

So I think this is it for now.

Thanks @jtojnar for your replies :slight_smile:

Hosted by Flying Circus.