Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 499b963

Browse filesBrowse files
committed
Fixed regression: 'lib uninstall' must operate only on user dir
1 parent 9b8ddcf commit 499b963
Copy full SHA for 499b963

File tree

Expand file treeCollapse file tree

2 files changed

+7
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-6
lines changed

‎arduino/libraries/librariesmanager/librariesmanager.go

Copy file name to clipboardExpand all lines: arduino/libraries/librariesmanager/librariesmanager.go
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ func (alts *LibraryAlternatives) Remove(library *libraries.Library) {
7878
}
7979

8080
// FindVersion returns the library mathching the provided version or nil if not found
81-
func (alts *LibraryAlternatives) FindVersion(version *semver.Version) *libraries.Library {
81+
func (alts *LibraryAlternatives) FindVersion(version *semver.Version, installLocation libraries.LibraryLocation) *libraries.Library {
8282
for _, lib := range alts.Alternatives {
83-
if lib.Version.Equal(version) {
83+
if lib.Version.Equal(version) && lib.Location == installLocation {
8484
return lib
8585
}
8686
}
@@ -245,7 +245,7 @@ func (lm *LibrariesManager) LoadLibraryFromDir(libRootDir *paths.Path, location
245245
// FindByReference return the installed library matching the Reference
246246
// name and version or, if the version is nil, the library installed
247247
// in the User folder.
248-
func (lm *LibrariesManager) FindByReference(libRef *librariesindex.Reference) *libraries.Library {
248+
func (lm *LibrariesManager) FindByReference(libRef *librariesindex.Reference, installLocation libraries.LibraryLocation) *libraries.Library {
249249
saneName := utils.SanitizeName(libRef.Name)
250250
alternatives, have := lm.Libraries[saneName]
251251
if !have {
@@ -254,11 +254,11 @@ func (lm *LibrariesManager) FindByReference(libRef *librariesindex.Reference) *l
254254
// TODO: Move "search into user" into another method...
255255
if libRef.Version == nil {
256256
for _, candidate := range alternatives.Alternatives {
257-
if candidate.Location == libraries.User {
257+
if candidate.Location == installLocation {
258258
return candidate
259259
}
260260
}
261261
return nil
262262
}
263-
return alternatives.FindVersion(libRef.Version)
263+
return alternatives.FindVersion(libRef.Version, installLocation)
264264
}

‎commands/lib/uninstall.go

Copy file name to clipboardExpand all lines: commands/lib/uninstall.go
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"context"
2020

2121
"github.com/arduino/arduino-cli/arduino"
22+
"github.com/arduino/arduino-cli/arduino/libraries"
2223
"github.com/arduino/arduino-cli/commands"
2324
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
2425
)
@@ -31,7 +32,7 @@ func LibraryUninstall(ctx context.Context, req *rpc.LibraryUninstallRequest, tas
3132
return &arduino.InvalidLibraryError{Cause: err}
3233
}
3334

34-
lib := lm.FindByReference(ref)
35+
lib := lm.FindByReference(ref, libraries.User)
3536

3637
if lib == nil {
3738
taskCB(&rpc.TaskProgress{Message: tr("Library %s is not installed", req.Name), Completed: true})

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.