golang/go · error
error opening file created by 'svn export': %v
Error message
error opening file created by 'svn export': %v
What it means
svnReadZip iterates over entries returned by `svn list` and opens each file produced by `svn export`. When os.Open fails with an error that is NOT IsNotExist (which has its own dedicated message), the generic opening error is returned with %v. Indicates a permission, I/O, or concurrency problem with the exported file, not a missing file.
Source
Thrown at src/cmd/go/internal/modfetch/codehost/svn.go:154
basePath := path.Join(path.Base(remote), subdir)
zw := zip.NewWriter(dst)
for _, e := range list.Entries {
if e.Kind != "file" {
continue
}
zf, err := zw.Create(path.Join(basePath, e.Name))
if err != nil {
return err
}
f, err := os.Open(filepath.Join(exportDir, e.Name))
if err != nil {
if os.IsNotExist(err) {
return vcsErrorf("file reported by 'svn list', but not written by 'svn export': %s", e.Name)
}
return fmt.Errorf("error opening file created by 'svn export': %v", err)
}
n, err := io.Copy(zf, f)
f.Close()
if err != nil {
return err
}
if n != e.Size {
return vcsErrorf("file size differs between 'svn list' and 'svn export': file %s listed as %v bytes, but exported as %v bytes", e.Name, e.Size, n)
}
}
return zw.Close()
}
View on GitHub (pinned to b6b368adc5)
Solutions
- Run `go clean -cache` to discard the corrupted svn export tree and retry.
- Ensure no other go command or svn process is concurrently using the same work directory.
- Check filesystem permissions and SELinux/AppArmor denials on GOCACHE and the export dir.
- Free disk space — svn export may have produced truncated files due to ENOSPC.
Defensive patterns
Strategy: retry
Try / catch
// svn export is racy with the filesystem — retry once after clearing the export dir.
err := svnReadZip(...)
if err != nil && strings.Contains(err.Error(), "error opening file created by 'svn export'") {
os.RemoveAll(exportDir)
err = svnReadZip(...)
} Prevention
- Serialise go commands that touch the same svn work dir to avoid export races.
- Keep GOCACHE on a healthy, writable filesystem with adequate free space.
- Prefer git-backed modules or the module proxy over svn to sidestep the export-scraping path.
When it happens
Trigger: File listed by `svn list` exists on disk after export but cannot be opened — permissions denied, file locked, race with another process removing it, or filesystem error.
Common situations: Concurrent go commands sharing an svn work directory; antivirus or SELinux denying reads of the export; svn export partially failed leaving zero-byte or locked files; disk full mid-export.
Related errors
- reading %s: %v
- failed to create cache directory: %w
- could not create module cache: %w
- codehost.WorkDir: can't find or create lock file: %v
- updating go.sum: %w
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/01bd4fca3b7e2ad9.
Report an issue: GitHub.