Skip to content

Commit

Permalink
crateNameFromCargoToml: make warnings more useful (ipetkov#282)
Browse files Browse the repository at this point in the history
* The warning now shows a more in-depth explanation on how to silence it
  • Loading branch information
ipetkov authored Mar 29, 2023
1 parent 72fa295 commit 6736e8b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/crateNameFromCargoToml.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ let
then "provided Cargo.toml contents"
else cargoToml;

traceMsg = tomlName: drvName: placeholder: lib.trivial.warn
"crane cannot find ${tomlName} attribute in ${debugPath}, consider setting `${drvName} = \"...\";` explicitly"
placeholder;
traceMsg = tomlName: drvName: placeholder: lib.flip lib.trivial.warn placeholder ''
crane will use a placeholder value since `${tomlName}` cannot be found in ${debugPath}
to silence this warning consider one of the following:
- setting `${drvName} = "...";` in the derivation arguments explicitly
- setting `package.${tomlName} = "..."` or `workspace.package.${tomlName} = "..."` in the root Cargo.toml
- explicitly looking up the values from a different Cargo.toml via
`craneLib.crateNameFromCargoToml { cargoToml = ./path/to/Cargo.toml; }`
'';

internalName = internalCrateNameFromCargoToml toml;
in
Expand Down

0 comments on commit 6736e8b

Please sign in to comment.