Skip to content

Commit

Permalink
Libraries dependencies: output error if no valid solution found (#544)
Browse files Browse the repository at this point in the history
Fix #534
  • Loading branch information
cmaglie committed Jan 30, 2020
1 parent cca6936 commit afdf259
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions commands/lib/resolve_deps.go
Expand Up @@ -42,6 +42,20 @@ func LibraryResolveDependencies(ctx context.Context, req *rpc.LibraryResolveDepe

// Resolve all dependencies...
deps := lm.Index.ResolveDependencies(reqLibRelease)

// If no solution has been found
if len(deps) == 0 {
// Check if there is a problem with the first level deps
for _, directDep := range reqLibRelease.GetDependencies() {
if _, ok := lm.Index.Libraries[directDep.GetName()]; !ok {
return nil, fmt.Errorf("dependency '%s' is not available", directDep.GetName())
}
}

// Otherwise there is no possible solution, the depends field has an invalid formula
return nil, fmt.Errorf("no valid solution found")
}

res := []*rpc.LibraryDependencyStatus{}
for _, dep := range deps {
// ...and add information on currently installed versions of the libraries
Expand Down
7 changes: 7 additions & 0 deletions test/test_lib.py
Expand Up @@ -60,6 +60,13 @@ def test_install(run_command):
assert run_command("lib install {}".format(" ".join(libs)))
assert run_command("lib install {}".format(" ".join(libs)))

# Test failing-install of library with wrong dependency
# (https://github.com/arduino/arduino-cli/issues/534)
result = run_command("lib install MD_Parola@3.2.0")
assert (
"Error resolving dependencies for MD_Parola@3.2.0: dependency 'MD_MAX72xx' is not available"
in result.stderr
)

def test_update_index(run_command):
result = run_command("lib update-index")
Expand Down

0 comments on commit afdf259

Please sign in to comment.