diff --git a/arduino/libraries/libraries_test.go b/arduino/libraries/libraries_test.go index ab9c5f129fa..9896ae577fb 100644 --- a/arduino/libraries/libraries_test.go +++ b/arduino/libraries/libraries_test.go @@ -54,12 +54,16 @@ func TestLibLayoutAndLocationJSONUnMarshaler(t *testing.T) { func TestLibrariesLoader(t *testing.T) { { - lib, err := Load(paths.New("testdata", "TestLib"), User) + libPath := paths.New("testdata", "TestLib") + lib, err := Load(libPath, User) require.NoError(t, err) require.Equal(t, "TestLib", lib.Name) require.Equal(t, "1.0.3", lib.Version.String()) require.False(t, lib.IsLegacy) require.False(t, lib.InDevelopment) + absPath, err := libPath.Abs() + require.NoError(t, err) + require.Equal(t, lib.InstallDir.String(), absPath.String()) } { lib, err := Load(paths.New("testdata", "TestLibInDev"), User) diff --git a/arduino/libraries/loader.go b/arduino/libraries/loader.go index 9af4b4fbf8e..2a106a37ae2 100644 --- a/arduino/libraries/loader.go +++ b/arduino/libraries/loader.go @@ -28,6 +28,13 @@ import ( // Load loads a library from the given LibraryLocation func Load(libDir *paths.Path, location LibraryLocation) (*Library, error) { + if !libDir.IsAbs() { + if abs, err := libDir.Abs(); err == nil { + libDir = abs + } else { + return nil, err + } + } if libDir.Join("library.properties").Exist() { return makeNewLibrary(libDir, location) }