@@ -23,6 +23,7 @@ import (
23
23
"net/url"
24
24
"os"
25
25
"path"
26
+ "runtime"
26
27
27
28
"github.com/arduino/arduino-cli/arduino/builder"
28
29
"github.com/arduino/arduino-cli/arduino/cores"
@@ -212,8 +213,15 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexReq, downloadCB Downlo
212
213
continue
213
214
}
214
215
216
+ logrus .WithField ("url" , URL ).Print ("Updating index" )
217
+
215
218
if URL .Scheme == "file" {
216
219
path := paths .New (URL .Path )
220
+ if runtime .GOOS == "windows" {
221
+ // Parsed local file URLs on Windows are returned with a leading /
222
+ // so we remove it
223
+ path = paths .New (URL .Path [1 :])
224
+ }
217
225
pathJSON , err := path .Abs ()
218
226
if err != nil {
219
227
return nil , fmt .Errorf ("can't get absolute path of %v: %w" , path , err )
@@ -223,7 +231,7 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexReq, downloadCB Downlo
223
231
return nil , fmt .Errorf ("invalid package index in %s: %s" , pathJSON , err )
224
232
}
225
233
226
- fi , _ := os .Stat (URL . Path )
234
+ fi , _ := os .Stat (path . String () )
227
235
downloadCB (& rpc.DownloadProgress {
228
236
File : "Updating index: " + pathJSON .Base (),
229
237
TotalSize : fi .Size (),
@@ -232,8 +240,6 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexReq, downloadCB Downlo
232
240
continue
233
241
}
234
242
235
- logrus .WithField ("url" , URL ).Print ("Updating index" )
236
-
237
243
var tmp * paths.Path
238
244
if tmpFile , err := ioutil .TempFile ("" , "" ); err != nil {
239
245
return nil , fmt .Errorf ("creating temp file for index download: %s" , err )
@@ -669,6 +675,11 @@ func createInstance(ctx context.Context, getLibOnly bool) (*createInstanceResult
669
675
670
676
if URL .Scheme == "file" {
671
677
path := paths .New (URL .Path )
678
+ if runtime .GOOS == "windows" {
679
+ // Parsed local file URLs on Windows are returned with a leading /
680
+ // so we remove it
681
+ path = paths .New (URL .Path [1 :])
682
+ }
672
683
pathJSON , err := path .Abs ()
673
684
if err != nil {
674
685
return nil , fmt .Errorf ("can't get absolute path of %v: %w" , path , err )
0 commit comments