apache/beam · error
error writing ta manifest file
Error message
error writing ta manifest file: %w
What it means
After rewriting the manifest with a Class-Path entry, MakeJar writes it back to tmpDir/META-INF/MANIFEST.MF with os.WriteFile and wraps any failure as "error writing ta manifest file" (typo for 'the'). It indicates the rewritten manifest could not be persisted, so the JAR would be repacked incorrectly or incompletely.
Solutions
- Check and fix write permissions on tmpDir and tmpDir/META-INF.
- Free disk space / raise quota on the volume holding cacheDir.
- Re-extract the JAR (remove cacheDir/tmpDir) so META-INF exists before the write.
- Point the cache at a writable directory (set BEAM_HOME or run with a user that owns cacheDir).
Example fix
// before
if err = os.WriteFile(tmpDir+"/META-INF/MANIFEST.MF", []byte(classpathString), 0660); err != nil {
return "", fmt.Errorf("error writing ta manifest file: %w", err)
}
// after: ensure target dir exists and is writable first
os.MkdirAll(tmpDir+"/META-INF", 0755)
os.Chmod(tmpDir+"/META-INF/MANIFEST.MF", 0660) // only if file pre-exists
if err = os.WriteFile(tmpDir+"/META-INF/MANIFEST.MF", []byte(classpathString), 0660); err != nil {
return "", fmt.Errorf("error writing manifest file: %w", err)
} Defensive patterns
Strategy: validation
Validate before calling
metaDir := filepath.Join(tmpDir, "META-INF")
if info, err := os.Stat(metaDir); err != nil || !info.IsDir() {
return errors.New("META-INF dir missing or not writable")
}
if err := unix.Access(metaDir, unix.W_OK); err != nil {
return fmt.Errorf("no write access to %s: %w", metaDir, err)
} Type guard
func isWriteDenied(err error) bool {
return errors.Is(err, fs.ErrPermission)
} Try / catch
jar, err := expansionx.MakeJar(ctx, target, repo, version)
if err != nil && strings.Contains(err.Error(), "manifest file") {
return fmt.Errorf("cache dir not writable, set a writable cache: %w", err)
} Prevention
- Point the cache at a directory writable by the service user.
- Watch disk quota/usage on the cache volume.
- Avoid read-only container filesystems for the cache path.
When it happens
Trigger: os.WriteFile fails because tmpDir/META-INF became read-only, the directory was deleted, the disk is full, or permission bits (0660) conflict with the filesystem (e.g. root-owned tmpDir).
Common situations: Running under a different user than the one who extracted the JAR; read-only container filesystem; SELinux/AppArmor restrictions on the cache location; disk quota exceeded.
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 in creating jar
- error accesing path
- error creating directory
- error in packJar()
- error opening file
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/0dfd11e1d6b75162.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/core/runtime/xlangx/expansionx/download.go:299
tmpDir := filepath.Join(cacheDir, "tmpDir")
if err := extractJar(mainJar, tmpDir); err != nil {
return "", fmt.Errorf("error in extractJar(): %w", err)
}
manifest, err := os.ReadFile(tmpDir + "/META-INF/MANIFEST.MF")
if err != nil {
return "", fmt.Errorf("error readingf: %w", err)
}
// trim the empty lines present at the end of MANIFEST.MF file.
manifestLines := strings.Split(string(manifest), "\n")
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)View on GitHub (pinned to 12126d8942)