Skip to content

Commit afdf259

Browse files
authored
Libraries dependencies: output error if no valid solution found (#544)
Fix #534
1 parent cca6936 commit afdf259

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Diff for: commands/lib/resolve_deps.go

+14
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ func LibraryResolveDependencies(ctx context.Context, req *rpc.LibraryResolveDepe
4242

4343
// Resolve all dependencies...
4444
deps := lm.Index.ResolveDependencies(reqLibRelease)
45+
46+
// If no solution has been found
47+
if len(deps) == 0 {
48+
// Check if there is a problem with the first level deps
49+
for _, directDep := range reqLibRelease.GetDependencies() {
50+
if _, ok := lm.Index.Libraries[directDep.GetName()]; !ok {
51+
return nil, fmt.Errorf("dependency '%s' is not available", directDep.GetName())
52+
}
53+
}
54+
55+
// Otherwise there is no possible solution, the depends field has an invalid formula
56+
return nil, fmt.Errorf("no valid solution found")
57+
}
58+
4559
res := []*rpc.LibraryDependencyStatus{}
4660
for _, dep := range deps {
4761
// ...and add information on currently installed versions of the libraries

Diff for: test/test_lib.py

+7
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ def test_install(run_command):
6060
assert run_command("lib install {}".format(" ".join(libs)))
6161
assert run_command("lib install {}".format(" ".join(libs)))
6262

63+
# Test failing-install of library with wrong dependency
64+
# (https://github.com/arduino/arduino-cli/issues/534)
65+
result = run_command("lib install [email protected]")
66+
assert (
67+
"Error resolving dependencies for [email protected]: dependency 'MD_MAX72xx' is not available"
68+
in result.stderr
69+
)
6370

6471
def test_update_index(run_command):
6572
result = run_command("lib update-index")

0 commit comments

Comments
 (0)