apache/beam · error
error in packJar()
Error message
error in packJar(): %w
What it means
After chdir-ing into tmpDir, MakeJar calls packJar(".", tmpJar) to create a zip of the extracted contents at cacheDir/tmp.jar; any packing failure (zip create/write error) is wrapped as "error in packJar()".
Solutions
- Ensure cacheDir is writable and has enough free space.
- Stop concurrent processes touching tmpDir, clean it, and retry.
- Unwrap the error to identify the specific file that failed to be written/read.
- Check for unreadable files/symlinks in tmpDir before packing.
Defensive patterns
Strategy: try-catch
Validate before calling
tmpJar := filepath.Join(cacheDir, "tmp.jar")
if f, err := os.Create(tmpJar); err != nil {
return fmt.Errorf("cannot write tmp.jar in cacheDir: %w", err)
} else {
f.Close()
os.Remove(tmpJar)
} Try / catch
jar, err := expansionx.MakeJar(ctx, target, repo, version)
var pe *fs.PathError
if err != nil && errors.As(err, &pe) && errors.Is(pe.Err, fs.ErrPermission) {
return fmt.Errorf("check cacheDir permissions/disk space: %w", err)
} Prevention
- Ensure adequate free space in cacheDir before starting.
- Avoid concurrent runs sharing one cacheDir.
- Confirm the service user can create files in cacheDir.
When it happens
Trigger: packJar fails because tmp.jar cannot be created in cacheDir (permissions, disk full), or a file inside tmpDir cannot be read/zipped (disappeared mid-walk, symlink issues, unreadable entries).
Common situations: Cache directory not writable by the service user; files added/removed in tmpDir while packing due to concurrent runs; oversized contents exceeding disk quota.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- error copying file
- error creating jarFile header
- error getting FileInfoHeader
- error in creating jar
- error in extractJar()
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/8dcb7111f01389c5.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go:313
manifestLines = manifestLines[:len(manifestLines)-2]
classpathString := fmt.Sprintf("%sClass-Path: %s\n", strings.Join(manifestLines, "\n"), strings.Join(relClasspath, " "))
if err = os.WriteFile(tmpDir+"/META-INF/MANIFEST.MF", []byte(classpathString), 0660); err != nil {
return "", fmt.Errorf("error writing ta manifest file: %w", err)
}
path, err := os.Getwd()
if err != nil {
return "", fmt.Errorf("can't get current working directory: %w", err)
}
if err = os.Chdir(tmpDir); err != nil {
return "", fmt.Errorf("can't change to temp directory %s for creating JAR: %w", tmpDir, err)
}
tmpJar := filepath.Join(cacheDir, "tmp.jar")
if err = packJar(".", tmpJar); err != nil {
return "", fmt.Errorf("error in packJar(): %w", err)
}
if err = os.Chdir(path); err != nil {
return "", fmt.Errorf("can't change to old working directory %s: %w", path, err)
}
return tmpJar, nil
}
// GetBeamJar checks a temporary directory for the desired Beam JAR, downloads the
// appropriate JAR from Maven if not present, then returns the file path to the
// JAR.
func GetBeamJar(gradleTarget, version string) (string, error) {
return defaultJarGetter.getJar(gradleTarget, version)
}
func (j *jarGetter) getRepositoryURL() string {
return string(j.repository)View on GitHub (pinned to 12126d8942)