Skip to content

Installing a package with outputSpecified in nix-env will cause subsequent installations to fail #12707

Open
@markasoftware

Description

@markasoftware

Describe the bug

If a package whose derivation has an outputSpecified attribute not equal to whatever output would be the default without outputSpecified attribute is installed via nix-env, the specified output is installed, but subsequent installation of any package will cause a mysterious-looking this derivation has bad 'meta.outputsToInstall' to appear.

Most commonly, specifying the .dev or .src (or another output name) attribute inside a package will produce a version of that package with outputSpecified set. But for some reason, on subsequent installations of other packages, nix-env tries to realize a derivation that presumably does not have outputSpecified set, has outputs not set to the original package's full set of outputs (only the output that was originally outputSpecified), but has meta.outputsToInstall equal to the original derivation's meta.outputsToInstall, which is now not in the list of outputs. I don't fully understand this bug.

It's as if nix-env saves a derivation for each package it installs and somehow the one it saves for a package with outputSpecified doesn't have that outputSpecified anymore?

Steps To Reproduce

With the latest version of nix-env, in a new profile, run:

nix-env --profile test-profile -iA nixpkgs.SDL2.dev  # succeeds
nix-env --profile test-profile -iA nixpkgs.navidrome  # fails with bad outputsToInstall error

After nixpkgs.SDL2.dev has been installed, we have:

nix-env --profile test-profile -q --json

{
  "0": {
    "name": "SDL2-2.32.0",
    "outputName": "",
    "outputs": {
      "dev": null
    },
    "pname": "SDL2",
    "system": "x86_64-linux",
    "version": "2.32.0"
  },
}

the "out" output is missing but "outputName" is not set.

Expected behavior

It's unclear to me what the recommended way of installing a specific output with nix-env is, but I certainly don't think installing a package like this should cause spooky action-at-a-distance failures later.

Additionally, the error message this derivation has bad 'meta.outputsToInstall' is hard to understand because it doesn't say which package had bad meta.outputsToInstall (which, of course, led me to believe that the second package I was installing was the problem, not the one already installed)

This is probably the cause of https://discourse.nixos.org/t/error-this-derivation-has-bad-meta-outputstoinstall/20019, https://www.reddit.com/r/NixOS/comments/1avc7a7/when_package_a_python_app_failed_with_this/, NixOS/nixpkgs#189555, https://discourse.nixos.org/t/error-during-un-installing-packages/58772, zombiezen/codespaces-nix#6, #9340 and a number of other reports throughout the web.


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions