diff --git a/internal/install/source.go b/internal/install/source.go index ba39c099a..6c61ca431 100644 --- a/internal/install/source.go +++ b/internal/install/source.go @@ -559,7 +559,10 @@ func parseFileURL(matches []string, source *Source) (*Source, error) { } source.Type = SourceTypeGitHTTPS // Treat as git for cloning - source.CloneURL = "file://" + path + // filepath.Clean rewrites the separators for the local OS, but a file:// URL + // keeps forward slashes everywhere; on Windows the raw path would produce + // `file://\path\to\repo`, which git does not accept as a local repository. + source.CloneURL = "file://" + filepath.ToSlash(path) if err := validateCloneURL(source.CloneURL); err != nil { return nil, err diff --git a/internal/install/source_test.go b/internal/install/source_test.go index 1dca2003f..59747865b 100644 --- a/internal/install/source_test.go +++ b/internal/install/source_test.go @@ -595,6 +595,13 @@ func TestParseSource_FileURL(t *testing.T) { wantCloneURL: "file:///path/to/repo", wantName: "repo", }, + { + // On Windows filepath.Clean would otherwise emit `file://\C:\...`. + name: "file url with a drive path keeps URL separators", + input: "file:///C:/path/to/repo", + wantCloneURL: "file:///C:/path/to/repo", + wantName: "repo", + }, { name: "file url with dot suffix normalized to root", input: "file:///path/to/repo/.",