lib: clear error when a dependency's library was not in the install plan - #2550
Open
hamishmack wants to merge 1 commit into
Open
lib: clear error when a dependency's library was not in the install plan#2550hamishmack wants to merge 1 commit into
hamishmack wants to merge 1 commit into
Conversation
dependToLib silently relied on `d.components.library`, so depending on a package that is unplanned (but carries overrides) failed with an opaque `attribute 'library' missing` error. A package value carries its `identifier`, so when the library component is absent we now throw a message naming the package and explaining it was not in the install plan (add it to the plan, or drop the override). Only the previously-failing branch changes; when the library is present the result is unchanged, and checking `d.components ? library` adds no strictness (the normal path already forces `d.components`). Adds test/unit.nix cases: library resolves, sublib passthrough, and an unplanned package throws.
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.
Fixes the opaque error reported in #1379.
Problem
When a package is unplanned (not in the cabal install plan) but has been given overrides, depending on it failed with an unhelpful
attribute 'library' missingerror pointing deep insidepackages.<x>.components.library.dependToLib(lib/default.nix) had a comment noting anassertwould be nicer "but there is currently no good way to get the name of the dependency when it is not in the plan".Fix
A package value carries its
identifierat the top level (builder/hspkg-builder.nix), and an unplanned package simply lacks alibraryundercomponents(allComponentfilters tobuildable && planned). So the name is reachable.dependToLibnow, in the missing-library branch only, throws a clear message naming the package and explaining it was not in the install plan (add it to the plan, or drop the override).libraryis present the result is byte-identical.d.componentsto read.library, sod.components ? librarycosts nothing.Tests
Added
test/unit.nixcases exercising the realhaskellLib.dependToLib: library resolves, sublib (nocomponents) passes through, and an unplanned package throws. Fullunit.testssuite eval →[](pass) underghc9124. Verified out of band that the real throw reads:A normal project is unaffected (the normal path is unchanged); I did not run a full project eval (needs plan-nix IFD + network).
Follow-up (out of scope)
The plan also floated stubbing the throw at component-assembly time so direct
hsPkgs.<pkg>.components.libraryaccess gives the same message; this PR keeps the change minimal and targeted at the reported dependency path.Closes #1379.