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

'nix build --dry-run' fails on new derivations, acts like readOnlyMode #1795

Closed
dtzWill opened this issue Jan 12, 2018 · 7 comments
Closed
Assignees

Comments

@dtzWill
Copy link
Member

dtzWill commented Jan 12, 2018

Using nixpkgs master (shouldn't matter which, but):

$ git rev-parse HEAD
6887a0fc9a802331a2d77b499f9692548899c84c

Using nix build --dry-run on an installable we don't have a .drv file for, fails:

$ nix build -f . --dry-run android-studio
don't know how to build these paths (may be caused by read-only store access):
  /nix/store/0fp7f41a6s1zfha98qf6180qghc3858y-android-studio-3.0.1.0.drv!out

Which honestly is an error I've only seen when doing unusual things previously.

nix-build on the same works as expected:

$ nix-build --dry-run -A android-studio
these derivations will be built:
  /nix/store/0fp7f41a6s1zfha98qf6180qghc3858y-android-studio-3.0.1.0.drv
these paths will be fetched (645.11 MiB download, 1151.45 MiB unpacked):
  /nix/store/5h6zhfg68lzih2r8v4bj3dqi7bkwlfml-android-studio-fhs-env-fhs
  /nix/store/8ai9s4h4x1hwszaf8mp1dl1pbnx1cjxb-android-studio
  /nix/store/955pgx40p0iz4vss7yk0b7ahc7hi1k5n-android-studio-fhs-env-init
  /nix/store/d1q9aypz215rg59bb1fgymjr0qicnymf-android-studio-fhs-env-usr-target
  /nix/store/ihdlxc3gqvj1ak9pjg521yiv0a5niqpp-android-studio-fhs-env-chrootenv-etc
  /nix/store/jdpkx4dwr7sr95dfy93vvcl3fx59sfc4-profile
  /nix/store/lrxd00h7cq8ffqrrgx3c81bfyj2gzwyr-android-studio-fhs-env-usr-multi
  /nix/store/nq7bid5yn9gia84g43aiznrs2z8jxcl6-android-studio-fhs-env
  /nix/store/xwxcr2gjv23dy8svjpv2mrqnfynrdq69-fonts.conf

And since it instantiates the .drv file, nix build works again:

$ nix build -f . --dry-run android-studio
these derivations will be built:
  /nix/store/0fp7f41a6s1zfha98qf6180qghc3858y-android-studio-3.0.1.0.drv
these paths will be fetched (645.11 MiB download, 1151.45 MiB unpacked):
  /nix/store/5h6zhfg68lzih2r8v4bj3dqi7bkwlfml-android-studio-fhs-env-fhs
  /nix/store/8ai9s4h4x1hwszaf8mp1dl1pbnx1cjxb-android-studio
  /nix/store/955pgx40p0iz4vss7yk0b7ahc7hi1k5n-android-studio-fhs-env-init
  /nix/store/d1q9aypz215rg59bb1fgymjr0qicnymf-android-studio-fhs-env-usr-target
  /nix/store/ihdlxc3gqvj1ak9pjg521yiv0a5niqpp-android-studio-fhs-env-chrootenv-etc
  /nix/store/jdpkx4dwr7sr95dfy93vvcl3fx59sfc4-profile
  /nix/store/lrxd00h7cq8ffqrrgx3c81bfyj2gzwyr-android-studio-fhs-env-usr-multi
  /nix/store/nq7bid5yn9gia84g43aiznrs2z8jxcl6-android-studio-fhs-env
  /nix/store/xwxcr2gjv23dy8svjpv2mrqnfynrdq69-fonts.conf

This is breaks one of my primary uses for --dry-build: using it after modifying expressions to see what the fallout is. Anyway I don't think it's quite the intention of --dry-run anyway.


FWIW this seems to have been introduced in c36467a#diff-fc4f446fc21b1365be7f6339ceb8efe8L232 although I'm not sure why, haven't looked too closely.

@Ericson2314
Copy link
Member

I haven't looked at diff, but I could see the temptation to reduce use less fewer privileges in a dry-run case. Agreed with @dtzWill this destroys one of the primary use-cases of --dry-run so we should fix by any means necessary, but more long term its more motivation to better support in-memory drvs

@shlevy shlevy added the backlog label Apr 1, 2018
@shlevy shlevy self-assigned this Apr 1, 2018
@dtzWill
Copy link
Member Author

dtzWill commented Nov 5, 2019

Beep boop!

  • is this indeed a bug, and not desired behavior?
  • maybe someone wants to take a look at fixing? :)

@danbst
Copy link
Contributor

danbst commented Jan 5, 2020

was hit by this as well! --dry-run should instantiate stuff, right? cc @edolstra

@madjar
Copy link
Member

madjar commented Jan 13, 2020

I looked into why it was behaving that way, and it looks like the build command sets the readOnlyMode (while legacy nix-build) did not:

https://github.com/NixOS/nix/blob/master/src/nix/installables.cc#L253-L254

If that's not the desired behaviour, then removing these two lines should be enough. It looks like no other command is calling that function, so it should not have any side-effect.

madjar added a commit to madjar/nix that referenced this issue Jul 3, 2020
In dry run mode, new derivations can't be create, so running the command on anything that has not been evaluated before results in an error message of the form `don't know how to build these paths (may be caused by read-only store access)`.

For comparison, the classical `nix-build --dry-run` doesn't use read-only mode.

Closes NixOS#1795
madjar added a commit to madjar/nix that referenced this issue Jul 22, 2020
In dry run mode, new derivations can't be create, so running the command on anything that has not been evaluated before results in an error message of the form `don't know how to build these paths (may be caused by read-only store access)`.

For comparison, the classical `nix-build --dry-run` doesn't use read-only mode.

Closes NixOS#1795
madjar added a commit to madjar/nix that referenced this issue Jul 22, 2020
In dry run mode, new derivations can't be create, so running the command on anything that has not been evaluated before results in an error message of the form `don't know how to build these paths (may be caused by read-only store access)`.

For comparison, the classical `nix-build --dry-run` doesn't use read-only mode.

Closes NixOS#1795
madjar added a commit to madjar/nix that referenced this issue Aug 3, 2020
In dry run mode, new derivations can't be create, so running the command on anything that has not been evaluated before results in an error message of the form `don't know how to build these paths (may be caused by read-only store access)`.

For comparison, the classical `nix-build --dry-run` doesn't use read-only mode.

Closes NixOS#1795
@anka-213
Copy link

I think I ran into this problem too. I was using callCabal2nix, which uses IFD and got the error

error: --- EvalError ----------------------------------------------- nix
at: (83:54) in file: /nix/store/h3qd1vw6cfppz75jf49fa3d73c0sgw06-source/pkgs/development/haskell-modules/make-package-set.nix

    82|       # info that callPackage uses to determine the arguments).
    83|       drv = if stdenv.lib.isFunction fn then fn else import fn;
      |                                                      ^
    84|       auto = builtins.intersectAttrs (stdenv.lib.functionArgs drv) scope;

cannot import '/nix/store/lf5277jq85fr89pp90r2rrzk2vdlyxrn-cabal2nix-gf', since path '/nix/store/lavrxplp0lhv3aa2s56qx47sr51q5gwj-cabal2nix-gf.drv' is not valid
(use '--show-trace' to show detailed location information)

After that, even if I tried without --dry-run I got

error: --- CachedEvalError --------------------------------------- nix
cached failure of attribute 'packages.x86_64-darwin.gf'

madjar added a commit to madjar/nix that referenced this issue Feb 24, 2021
In dry run mode, new derivations can't be create, so running the command on anything that has not been evaluated before results in an error message of the form `don't know how to build these paths (may be caused by read-only store access)`.

For comparison, the classical `nix-build --dry-run` doesn't use read-only mode.

Closes NixOS#1795
@Atemu
Copy link
Member

Atemu commented Feb 27, 2021

Could the dry-run flag be split into a completely dry run (--arid-run?) and a dry run that still instantiates perhaps?

@anka-213
Copy link

Could the dry-run flag be split into a completely dry run (--arid-run?) and a dry run that still instantiates perhaps?

That would be especially nice if --arid-run could show what --dry-run would download and instantiate instead of just crashing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants