aliases.nix: always include attr name in error msg#101210
Closed
9999years wants to merge 1 commit intoNixOS:masterfrom
Closed
aliases.nix: always include attr name in error msg#1012109999years wants to merge 1 commit intoNixOS:masterfrom
9999years wants to merge 1 commit intoNixOS:masterfrom
Conversation
aliases.nix: errors should include package names In `pkgs/top-level/aliases.nix`, `throw` was used to make packages that were removed error with a more useful message than "attribute 'foobar' missing, at <location>". However, if the error message doesn't include the package's attribute name, it can be difficult to determine what caused it. For example, here's what building a configuration that referenced `ytop` looked like recently (see NixOS#101098): ``` $ nixos-rebuild switch building Nix... building the system configuration... error: Abandoned by upstream. Consider switching to bottom instead (use '--show-trace' to show detailed location information) ``` Therefore, we modify string values in `aliases.nix` to prefix `Attribute foobar in <nixpkgs> has been removed` to the reason message. This makes the removed reasons a bit shorter and provides a place to unilaterally improve these error messages in the future, rather than with one-off changes or large sets of manual fixes.
cole-h
reviewed
Oct 20, 2020
| # avoid confusing errors: | ||
| # https://github.com/NixOS/nixpkgs/pull/101098 | ||
| if lib.isString alias then | ||
| throw "Attribute ${n} in <nixpkgs> has been removed; ${alias}" |
Member
There was a problem hiding this comment.
<nixpkgs> might not always exist (e.g. in a flakes-based system). Maybe just s/<nixpkgs>/Nixpkgs/?
Member
|
I think this would be a great addition but we also would need more people on agreeing if we want this because otherwise @9999years is fixing merge conflicts forever. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
pkgs/top-level/aliases.nix,throwwas used to make packages that were removed error with a more useful message thanattribute 'foobar' missing, at <location>.However, if the error message doesn't include the package's attribute name, it can be difficult to determine what caused it. For example, here's what building a configuration that referenced
ytoplooked like recently (see #101098):Therefore, we modify string values in
aliases.nixto prefixAttribute foobar in <nixpkgs> has been removedto the reason message. This makes the removed reasons a bit shorter and provides a place to unilaterally improve these error messages in the future, rather than with one-off changes or large sets of manual fixes.Built/tested on NixOS.