@@ -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}
0 commit comments