nix icon indicating copy to clipboard operation
nix copied to clipboard

"bad meta.outputsToInstall" error when installing packages

Open jvns opened this issue 2 years ago • 4 comments

Describe the bug

Sometimes when I run nix-env -iA nixpkgs.somepackage, I get a bad meta.outputsToInstall error, like this:

$  nix-env -iA nixpkgs.cheat
installing 'cheat-4.4.0'
this path will be fetched (6.23 MiB download, 16.11 MiB unpacked):
 /nix/store/k95iy2ajg4zipvpawk7fz83cpy9y1ha7-cheat-4.4.0
copying path '/nix/store/k95iy2ajg4zipvpawk7fz83cpy9y1ha7-cheat-4.4.0' from 'https://cache.nixos.org'...
error: this derivation has bad 'meta.outputsToInstall'

It happens when I try to install any package -- nix is just completely broken.

This happens every 2-3 months with no obvious-to-me pattern. The only way I know to fix it is to run this bash script, which always fixes the problem. I don't understand what that script does though.

Steps To Reproduce

I don't know, but I know it's happened to me repeatedly. Reporting it in case someone else can figure out how to reproduce it or is running into the same issue.

Expected behavior

It seems weird that I need to do a seemingly stateful thing like "rebuild my profile" since nix is supposed to be stateless -- it's surprising to me that the system just breaks for no apparent reason every few months.

nix-env --version output

nix-env (Nix) 2.11.1

jvns avatar Nov 12 '23 15:11 jvns

I had the same problem with bad meta.outputsToInstall. I couldn't install or uninstall anything, and the script you linked to didn't work either, but I found this and that helped me. Don't know why though and I don't know what I did to end up with this error.

mokshasoft avatar Nov 14 '23 06:11 mokshasoft

I had (and still have) the exact same issue with nix (Nix) 2.13.5 in docker. This is quite annoying, no topic nor any issue seems to properly address the root cause of this situation.

It seems some packages install tend to trigger it more than others (for me an good example is nixpkgs.dog) but I'm not even sure this is correlated.

TL;DR there are 2 workaround hacks:

nix-env -u --always
OR
nix-env --list-generations
nix-env --rollback

I'm still on the Nix learning phase tho, maybe this is just a normal behavior that is out of my understanding for some reason.

Edit: FYI I'm using channel nixpkgs-unstable but I had the exact same issue with Nix 2.11.1 and channels 22.05

senges avatar Nov 16 '23 10:11 senges

I also stumbled upon this problem and have a Dockerfile to reproduce it.

FROM nixos/nix:2.24.9
RUN nix-env -iA nixpkgs.gnused
RUN nix-env -iA nixpkgs.crane
RUN nix-env -iA nixpkgs.devenv

On my PC this always leads to: error: this derivation has bad 'meta.outputsToInstall' for the devenv package.

Interestingly, this doesn't happen if I change the order:

FROM nixos/nix:2.24.9
RUN nix-env -iA nixpkgs.devenv
RUN nix-env -iA nixpkgs.gnused
RUN nix-env -iA nixpkgs.crane

This builds without problems. The used build command is: docker build -t nix-test .

Maybe somebody can have a look into this to see why the environment breaks.

sven avatar Oct 10 '24 14:10 sven

Maybe I found something that could help debugging this issue. After installing crane, which seems to break nix-env, I looked into the manifest.nix and found this:

[
  {
    crane = ...
    meta =  {
      outputsToInstall = ["out"];
    };
    outputs = ["crane"];
  }
  ...
]

As you can see, the meta.outputsToInstall doesn't match the outputs list. Other packages that don't break nix-env like jq and gnused have matching values.

sven avatar Oct 13 '24 10:10 sven

happens on slack and winbox as well.

Kek5chen avatar Dec 03 '24 12:12 Kek5chen

also happens with wireshark. this issue seems to literally break userspace installations.

Kek5chen avatar Dec 03 '24 14:12 Kek5chen