@@ -21,6 +21,7 @@ import (
2121 "fmt"
2222
2323 "github.com/arduino/arduino-cli/arduino"
24+ "github.com/arduino/arduino-cli/arduino/libraries"
2425 "github.com/arduino/arduino-cli/arduino/libraries/librariesindex"
2526 "github.com/arduino/arduino-cli/arduino/libraries/librariesmanager"
2627 "github.com/arduino/arduino-cli/commands"
@@ -30,13 +31,13 @@ import (
3031
3132// LibraryInstall FIXMEDOC
3233func LibraryInstall (ctx context.Context , req * rpc.LibraryInstallRequest , downloadCB rpc.DownloadProgressCB , taskCB rpc.TaskProgressCB ) error {
33-
3434 lm := commands .GetLibraryManager (req )
3535 if lm == nil {
3636 return & arduino.InvalidInstanceError {}
3737 }
3838
3939 toInstall := map [string ]* rpc.LibraryDependencyStatus {}
40+ installLocation := libraries .FromRPCLibraryInstallLocation (req .GetInstallLocation ())
4041 if req .NoDeps {
4142 toInstall [req .Name ] = & rpc.LibraryDependencyStatus {
4243 Name : req .Name ,
@@ -81,7 +82,7 @@ func LibraryInstall(ctx context.Context, req *rpc.LibraryInstallRequest, downloa
8182 // Check if any of the libraries to install is already installed and remove it from the list
8283 j := 0
8384 for i , libRelease := range libReleasesToInstall {
84- _ , libReplaced , err := lm .InstallPrerequisiteCheck (libRelease )
85+ _ , libReplaced , err := lm .InstallPrerequisiteCheck (libRelease , installLocation )
8586 if errors .Is (err , librariesmanager .ErrAlreadyInstalled ) {
8687 taskCB (& rpc.TaskProgress {Message : tr ("Already installed %s" , libRelease ), Completed : true })
8788 } else if err != nil {
@@ -104,7 +105,7 @@ func LibraryInstall(ctx context.Context, req *rpc.LibraryInstallRequest, downloa
104105 return err
105106 }
106107
107- if err := installLibrary (lm , libRelease , taskCB ); err != nil {
108+ if err := installLibrary (lm , libRelease , installLocation , taskCB ); err != nil {
108109 if errors .Is (err , librariesmanager .ErrAlreadyInstalled ) {
109110 continue
110111 } else {
@@ -123,10 +124,10 @@ func LibraryInstall(ctx context.Context, req *rpc.LibraryInstallRequest, downloa
123124 return nil
124125}
125126
126- func installLibrary (lm * librariesmanager.LibrariesManager , libRelease * librariesindex.Release , taskCB rpc.TaskProgressCB ) error {
127+ func installLibrary (lm * librariesmanager.LibrariesManager , libRelease * librariesindex.Release , installLocation libraries. LibraryLocation , taskCB rpc.TaskProgressCB ) error {
127128 taskCB (& rpc.TaskProgress {Name : tr ("Installing %s" , libRelease )})
128129 logrus .WithField ("library" , libRelease ).Info ("Installing library" )
129- libPath , libReplaced , err := lm .InstallPrerequisiteCheck (libRelease )
130+ libPath , libReplaced , err := lm .InstallPrerequisiteCheck (libRelease , installLocation )
130131 if errors .Is (err , librariesmanager .ErrAlreadyInstalled ) {
131132 taskCB (& rpc.TaskProgress {Message : tr ("Already installed %s" , libRelease ), Completed : true })
132133 return err
@@ -140,7 +141,7 @@ func installLibrary(lm *librariesmanager.LibrariesManager, libRelease *libraries
140141 taskCB (& rpc.TaskProgress {Message : tr ("Replacing %[1]s with %[2]s" , libReplaced , libRelease )})
141142 }
142143
143- if err := lm .Install (libRelease , libPath ); err != nil {
144+ if err := lm .Install (libRelease , libPath , installLocation ); err != nil {
144145 return & arduino.FailedLibraryInstallError {Cause : err }
145146 }
146147
0 commit comments