Skip to content

Commit 81431c0

Browse files
committed
Fix some commands failing when an installed library has invalid version
1 parent aa41922 commit 81431c0

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

arduino/libraries/librariesindex/index.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,9 @@ func (idx *Index) FindLibraryUpdate(lib *libraries.Library) *Release {
136136
if indexLib == nil {
137137
return nil
138138
}
139-
// library.Version is nil when when the version field in
140-
// a library descriptor is malformed and could not be parsed.
141-
if lib.Version == nil {
142-
return indexLib.Latest
143-
}
144-
if indexLib.Latest.Version.GreaterThan(lib.Version) {
139+
// If a library.properties has an invalid version property, usually empty or malformed,
140+
// the latest available version is returned
141+
if lib.Version == nil || indexLib.Latest.Version.GreaterThan(lib.Version) {
145142
return indexLib.Latest
146143
}
147144
return nil

arduino/libraries/librariesmanager/install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (lm *LibrariesManager) InstallPrerequisiteCheck(indexLibrary *librariesinde
5050
if installedLib.Location != libraries.User {
5151
continue
5252
}
53-
if installedLib.Version.Equal(indexLibrary.Version) {
53+
if installedLib.Version != nil && installedLib.Version.Equal(indexLibrary.Version) {
5454
return installedLib.InstallDir, nil, ErrAlreadyInstalled
5555
}
5656
replaced = installedLib

0 commit comments

Comments
 (0)