@@ -21,6 +21,7 @@ import (
21
21
"fmt"
22
22
23
23
"github.com/arduino/arduino-cli/arduino"
24
+ "github.com/arduino/arduino-cli/arduino/libraries"
24
25
"github.com/arduino/arduino-cli/arduino/libraries/librariesindex"
25
26
"github.com/arduino/arduino-cli/arduino/libraries/librariesmanager"
26
27
"github.com/arduino/arduino-cli/commands"
@@ -30,13 +31,13 @@ import (
30
31
31
32
// LibraryInstall FIXMEDOC
32
33
func LibraryInstall (ctx context.Context , req * rpc.LibraryInstallRequest , downloadCB rpc.DownloadProgressCB , taskCB rpc.TaskProgressCB ) error {
33
-
34
34
lm := commands .GetLibraryManager (req )
35
35
if lm == nil {
36
36
return & arduino.InvalidInstanceError {}
37
37
}
38
38
39
39
toInstall := map [string ]* rpc.LibraryDependencyStatus {}
40
+ installLocation := libraries .FromRPCLibraryInstallLocation (req .GetInstallLocation ())
40
41
if req .NoDeps {
41
42
toInstall [req .Name ] = & rpc.LibraryDependencyStatus {
42
43
Name : req .Name ,
@@ -81,7 +82,7 @@ func LibraryInstall(ctx context.Context, req *rpc.LibraryInstallRequest, downloa
81
82
// Check if any of the libraries to install is already installed and remove it from the list
82
83
j := 0
83
84
for i , libRelease := range libReleasesToInstall {
84
- _ , libReplaced , err := lm .InstallPrerequisiteCheck (libRelease )
85
+ _ , libReplaced , err := lm .InstallPrerequisiteCheck (libRelease , installLocation )
85
86
if errors .Is (err , librariesmanager .ErrAlreadyInstalled ) {
86
87
taskCB (& rpc.TaskProgress {Message : tr ("Already installed %s" , libRelease ), Completed : true })
87
88
} else if err != nil {
@@ -104,7 +105,7 @@ func LibraryInstall(ctx context.Context, req *rpc.LibraryInstallRequest, downloa
104
105
return err
105
106
}
106
107
107
- if err := installLibrary (lm , libRelease , taskCB ); err != nil {
108
+ if err := installLibrary (lm , libRelease , installLocation , taskCB ); err != nil {
108
109
if errors .Is (err , librariesmanager .ErrAlreadyInstalled ) {
109
110
continue
110
111
} else {
@@ -123,10 +124,10 @@ func LibraryInstall(ctx context.Context, req *rpc.LibraryInstallRequest, downloa
123
124
return nil
124
125
}
125
126
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 {
127
128
taskCB (& rpc.TaskProgress {Name : tr ("Installing %s" , libRelease )})
128
129
logrus .WithField ("library" , libRelease ).Info ("Installing library" )
129
- libPath , libReplaced , err := lm .InstallPrerequisiteCheck (libRelease )
130
+ libPath , libReplaced , err := lm .InstallPrerequisiteCheck (libRelease , installLocation )
130
131
if errors .Is (err , librariesmanager .ErrAlreadyInstalled ) {
131
132
taskCB (& rpc.TaskProgress {Message : tr ("Already installed %s" , libRelease ), Completed : true })
132
133
return err
@@ -140,7 +141,7 @@ func installLibrary(lm *librariesmanager.LibrariesManager, libRelease *libraries
140
141
taskCB (& rpc.TaskProgress {Message : tr ("Replacing %[1]s with %[2]s" , libReplaced , libRelease )})
141
142
}
142
143
143
- if err := lm .Install (libRelease , libPath ); err != nil {
144
+ if err := lm .Install (libRelease , libPath , installLocation ); err != nil {
144
145
return & arduino.FailedLibraryInstallError {Cause : err }
145
146
}
146
147
0 commit comments