Skip to content

Libraries dependencies: output error if no valid solution found #544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions commands/lib/resolve_deps.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 [email protected]")
assert (
"Error resolving dependencies for [email protected]: dependency 'MD_MAX72xx' is not available"
in result.stderr
)

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