Skip to content

Commit afdf259

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

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

commands/lib/resolve_deps.go

Lines changed: 14 additions & 0 deletions
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

test/test_lib.py

Lines changed: 7 additions & 0 deletions
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 MD_Parola@3.2.0")
66+
assert (
67+
"Error resolving dependencies for MD_Parola@3.2.0: 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy