Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enableDebugging does not work anymore: error: attribute 'override' missing #136756

Closed
trofi opened this issue Sep 5, 2021 · 18 comments · Fixed by #147544
Closed

enableDebugging does not work anymore: error: attribute 'override' missing #136756

trofi opened this issue Sep 5, 2021 · 18 comments · Fixed by #147544
Assignees
Labels
0.kind: bug Something is broken 6.topic: stdenv Standard environment

Comments

@trofi
Copy link
Contributor

trofi commented Sep 5, 2021

Describe the bug

I tried to build a nixpkgs package with debug symbols today and failed. NixOS wiki and nixpkgs repository comments say the following should work:

Steps To Reproduce

$ nix-build -E 'with import <nixpkgs> {}; enableDebugging hello'

error: attribute 'override' missing

       at /nix/store/0skp33kj13x8fyx141qbcfn5q6a4xghw-nixos-21.11pre312407.8a2ec31e224/nixos/pkgs/stdenv/adapters.nix:210:5:

          209|   keepDebugInfo = stdenv:
          210|     stdenv.override (old: {
             |     ^
          211|       mkDerivationFromStdenv = extendMkDerivationArgs old (args: {

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.13.13, NixOS, 21.11 (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.4pre20210802_47e96bb`
 - channels(root): `"nixos-21.11pre312407.8a2ec31e224"`
 - channels(slyfox): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@trofi trofi added the 0.kind: bug Something is broken label Sep 5, 2021
@trofi
Copy link
Contributor Author

trofi commented Sep 5, 2021

It worked in Aug 2018: https://discourse.nixos.org/t/debug-symbols-for-nix-shell-and-nix-build/804/2?u=trofi

Bisected down to breakage at f110a18:

$ git bisect bad
f110a182a66005782c0e58091bcda7243bf2a0ae is the first bad commit
commit f110a182a66005782c0e58091bcda7243bf2a0ae
Author: John Ericson <[email protected]>
Date:   Mon Aug 16 21:16:29 2021 -0400

    stdenv: Fix overriding + `overrideAttrs`

    The old stdenv adapters were subtly wrong in two ways:

     - `overrideAttrs` leaked the original, unoverridden `mkDerivation`.

     - `stdenv.override` would throw away any manually-set `mkDerivation`
       from a stdenv reverting to the original.

    Now, `mkDerivation` is controlled (nearly directly) via an argument, and
    always correctly closes over the final ("self") stdenv. This means the
    adapters can work entirely via `.override` without any manual `stdenv //
    ...`, and both those issues are fixed.

    Note hashes are changed, because stdenvs no previously overridden like
    `stdenvNoCC` and `crossLibcStdenv` now are. I had to add some
    `dontDisableStatic = true` accordingly. The flip side however is that
    since the overrides compose, we no longer need to override anything but
    the default `stdenv` from which all the others are created.

 pkgs/os-specific/linux/musl/default.nix |   1 +
 pkgs/stdenv/adapters.nix                | 125 +++++++++++++++++++-------------
 pkgs/stdenv/generic/default.nix         |   8 +-
 pkgs/stdenv/generic/make-derivation.nix |  13 ++--
 pkgs/top-level/stage.nix                |   7 +-
 pkgs/top-level/static.nix               |  24 ------
 6 files changed, 94 insertions(+), 84 deletions(-)

Looks like it stems from the fact that hello.stdenv does not expose .override anymore, only .overrides.

/cc @Ericson2314 #134463

@veprbl veprbl added the 6.topic: stdenv Standard environment label Sep 5, 2021
@Ericson2314
Copy link
Member

Woah. master and f110a182a66005782c0e58091bcda7243bf2a0ae both work for me with nix stable.

@trofi
Copy link
Contributor Author

trofi commented Sep 6, 2021

That's surprising. Here is my attempt at current master checkout:

$ nix-build -I nixpkgs=. -E 'with import <nixpkgs> {}; enableDebugging hello'
error: attribute 'override' missing

       at /tmp/nixpkgs/pkgs/stdenv/adapters.nix:210:5:

          209|   keepDebugInfo = stdenv:
          210|     stdenv.override (old: {
             |     ^
          211|       mkDerivationFromStdenv = extendMkDerivationArgs old (args: {

I tried removing ~/.nixpkgs and seeing the same failure. I wonder why it works for you. Might be a different stdenv?

@trofi
Copy link
Contributor Author

trofi commented Sep 6, 2021

$ nix repl -I nixpkgs=. '<nixpkgs>'

Welcome to Nix version 2.4pre20210802_47e96bb. Type :? for help.

Loading '<nixpkgs>'...
Added 14887 variables.

nix-repl> stdenv
«derivation /nix/store/ikgr1jlpvyqa7nci7p8r138n440vy7q2-stdenv-linux.drv»

nix-repl> pkgs.hello.stdenv
«derivation /nix/store/ikgr1jlpvyqa7nci7p8r138n440vy7q2-stdenv-linux.drv»

nix-repl> stdenv.override
{ __functionArgs = { ... }; __functor = «lambda @ /tmp/nixpkgs/lib/trivial.nix:327:19»; }

nix-repl> pkgs.hello.stdenv.override<tab>
pkgs.hello.stdenv.overrides

Does it mean stdenv and pkgs.hello.stdenv are the same object?

@Artturin
Copy link
Member

Artturin commented Sep 8, 2021

i can reproduce

@alyssais
Copy link
Member

alyssais commented Sep 9, 2021

I can also reproduce with stable Nix (2.3.14):

$ NIX_PATH=nixpkgs=. nix-build -E 'with import <nixpkgs> {}; enableDebugging hello'
error: attribute 'override' missing, at /home/src/nixpkgs/pkgs/stdenv/adapters.nix:210:5

@Ericson2314
Copy link
Member

Hmm, the issue is that callPackage/makeOverridable slaps the .override on stdenv after stdenv.makeDerivation is defined, closing over the old stdenv. In Smalltalk paralance, this would be an issue of insufficiently "late binding".

@symphorien
Copy link
Member

Still reproducible on current master (2652e0b)

@deliciouslytyped
Copy link
Contributor

I ran into this.

@OPNA2608
Copy link
Contributor

OPNA2608 commented Oct 21, 2021

Bump, ran into this while updating the Nixpkgs pin on a project of mine.

@expipiplus1
Copy link
Contributor

There should be a test for this :)

@cab404
Copy link
Member

cab404 commented Nov 26, 2021

Gonna spend next hour or two trying to fix this.

@cab404
Copy link
Member

cab404 commented Nov 26, 2021

Things that are also missing:

[ "__bootPackages" "__hatPackages" "override" "overrideDerivation" ]

@cab404
Copy link
Member

cab404 commented Nov 26, 2021

https://github.com/NixOS/nixpkgs//blob/6078f094c638faabc63cffe285dc91af4e04a741/pkgs/stdenv/booter.nix#L89

So, this function is not executed on passed through stdenv. Not yet sure why.

@cab404
Copy link
Member

cab404 commented Nov 26, 2021

Yeah, I've fixed it (thanks, @mrgutkun, for being there ❤️)
#147544

@cab404
Copy link
Member

cab404 commented Nov 27, 2021

Post-mortem: always read threads. Solution was kinda already provided in #136756 (comment), but I delved right in without knowing that)

@Artturin
Copy link
Member

atleast you now know more about stdenv 🙂

@wesleywright
Copy link
Contributor

How is the PR looking? I've been waiting on this for a couple of weeks to debug an intermittent crash I'm having with xfce4-sesion :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: stdenv Standard environment
Projects
None yet
Development

Successfully merging a pull request may close this issue.