Skip to content

Commit c7b74fc

Browse files
committed
Fix local path parsing on Windows
1 parent 16cd87b commit c7b74fc

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

commands/instances.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"net/url"
2424
"os"
2525
"path"
26+
"runtime"
2627

2728
"github.com/arduino/arduino-cli/arduino/builder"
2829
"github.com/arduino/arduino-cli/arduino/cores"
@@ -212,8 +213,15 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexReq, downloadCB Downlo
212213
continue
213214
}
214215

216+
logrus.WithField("url", URL).Print("Updating index")
217+
215218
if URL.Scheme == "file" {
216219
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+
}
217225
pathJSON, err := path.Abs()
218226
if err != nil {
219227
return nil, fmt.Errorf("can't get absolute path of %v: %w", path, err)
@@ -232,8 +240,6 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexReq, downloadCB Downlo
232240
continue
233241
}
234242

235-
logrus.WithField("url", URL).Print("Updating index")
236-
237243
var tmp *paths.Path
238244
if tmpFile, err := ioutil.TempFile("", ""); err != nil {
239245
return nil, fmt.Errorf("creating temp file for index download: %s", err)
@@ -669,6 +675,11 @@ func createInstance(ctx context.Context, getLibOnly bool) (*createInstanceResult
669675

670676
if URL.Scheme == "file" {
671677
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+
}
672683
pathJSON, err := path.Abs()
673684
if err != nil {
674685
return nil, fmt.Errorf("can't get absolute path of %v: %w", path, err)

0 commit comments

Comments
 (0)