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

Error description for option conflicts #15747

Open
danbst opened this issue May 27, 2016 · 10 comments
Open

Error description for option conflicts #15747

danbst opened this issue May 27, 2016 · 10 comments

Comments

@danbst
Copy link
Contributor

danbst commented May 27, 2016

Issue description

I think, that error description for module options conflict is not newbie friendly. At least it should mention the ways to solve this conflict, e.g. lib.mkForce or lib.mkOverride. For example, you cannot set this option

Steps to reproduce

module1:

{ networking.firewall.enable = true; }

module2:

{
   imports = [ ./module1.nix ];
   networking.firewall.enable = false;
}

results into

building Nix...
building the system configuration...
error: The option `networking.firewall.enable' has conflicting definitions, in `/etc/nixos/services/module.nix' and `<unknown-file>'.
(use ‘--show-trace’ to show detailed location information)

Example 2: one-liner

  containers.t.config.imports = [ <nixpkgs/nixos/modules/virtualisation/amazon-image.nix> ];
building Nix...
building the system configuration...
error: The unique option `containers.t.networking.hostName' is defined multiple times, in `/nix/store/28wbqc87ygsm1h1zzim2w843fa35iyz4-nixexprs.tar.xz/nixos/modules/virtualisation/amazon-image.nix' and `<unknown-file>'.

Technical details

  • System: 16.03.858.b8d7324 (Emu)
@Profpatsch
Copy link
Member

cc @nbp

@nbp nbp self-assigned this Jul 8, 2018
@nbp
Copy link
Member

nbp commented Jul 8, 2018

Thanks for the report, about the fact that NixOS error messages do not describe any way to solve the issue which is reported.

I will look into it.

@davidak
Copy link
Member

davidak commented May 27, 2019

Sometimes it even don't describe where the issue is, like:

error: The unique option `containers.target0.networking.hostName' is defined multiple times, in `<unknown-file>' and `<unknown-file>'.

I would consider <unknown-file> a bug since Nix should know where the conflict is.

My code:

configuration.nix

{ config, pkgs, ... }:

let
  target = import ../gvm-test-target-container/configuration.nix;
in
{
...
  containers = {
    target0 = {
      config = target;
    };
  };

../gvm-test-target-container/configuration.nix

{ config, lib, pkgs, ... }:

{ boot.isContainer = true;
  networking.hostName = mkDefault "foo";
  networking.useDHCP = false;
  networking.firewall.enable = false;
...
}

danbst added a commit to danbst/nixpkgs that referenced this issue Jun 5, 2019
The error can be reproduced like:
```
$ nix-instantiate ./nixos -A system --arg configuration '
  { fileSystems."/".device = "nodev";
    boot.loader.grub.devices = [ "nodev" ];
    containers.t.config.imports = [ <nixpkgs/nixos/modules/virtualisation/amazon-image.nix> ];
  }'
```

Previously error was:
```
error: The unique option `containers.t.networking.hostName' is defined multiple times, in `/nix/var/nix/profiles/per-user/root/channels/nixpkgs/nixos/modules/virtualisation/amazon-image.nix' and `module at /home/danbst/dev/nixpkgs/nixos/modules/virtualisation/containers.nix:470'.
(use '--show-trace' to show detailed location information)
```

Now it is:
```
error: The unique option `containers.t.networking.hostName' is defined multiple times, in:
 - /nix/var/nix/profiles/per-user/root/channels/nixpkgs/nixos/modules/virtualisation/amazon-image.nix
 - module at /home/danbst/dev/nixpkgs/nixos/modules/virtualisation/containers.nix:470.
(use '--show-trace' to show detailed location information)
```

Related: NixOS#15747
danbst added a commit to danbst/nixpkgs that referenced this issue Jun 5, 2019
See NixOS#15747. Previously this module was called `<unknown-file>`
in error messages, now it is called a bit more close to real:
```
module at /home/danbst/dev/nixpkgs/nixos/modules/virtualisation/containers.nix:470
```
@stale
Copy link

stale bot commented Jun 2, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 2, 2020
@samuela
Copy link
Member

samuela commented Jan 20, 2021

It would still be helpful to get a more actionable error message here. In particular something pointing users towards mkForce, mkOverride, etc.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 20, 2021
@stale
Copy link

stale bot commented Jul 19, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 19, 2021
@samuela
Copy link
Member

samuela commented Jul 19, 2021

Still an issue.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 19, 2021
@stale
Copy link

stale bot commented May 1, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label May 1, 2022
@montchr
Copy link
Member

montchr commented Dec 27, 2022

Still an issue, yes. I found my way to this issue while looking for advice about tracking down an <unknown-file>. Better advice around resolving option conflicts is one thing, but <unknown-file> feels to me like it compounds upon the issue even further.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 27, 2022
@bobvanderlinden
Copy link
Member

bobvanderlinden commented Jun 9, 2023

I think this is solved by #62712, b3cc29c and fe734ef

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

No branches or pull requests

8 participants