{"record":{"id":"45a093607c3355ad","repo":"apache/maven","slug":"could-not-write-fixed-metadata-to","errorCode":null,"errorMessage":"Could not write fixed metadata to {}: {}","messagePattern":"Could not write fixed metadata to (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"compat/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java","lineNumber":318,"sourceCode":"                            .warn(\"The last updated timestamp in \" + metadataFile + \" refers to the future (now = \"\n                                    + now\n                                    + \", lastUpdated = \" + lastUpdated + \"). Please verify that the clocks of all\"\n                                    + \" deploying machines are reasonably synchronized.\");\n                    versioning.setLastUpdated(now);\n                    changed = true;\n                }\n            }\n        }\n\n        if (changed) {\n            getLogger().debug(\"Repairing metadata in \" + metadataFile);\n\n            try (OutputStream out = Files.newOutputStream(metadataFile.toPath())) {\n                new MetadataStaxWriter().write(out, metadata.getDelegate());\n            } catch (IOException | XMLStreamException e) {\n                String msg = \"Could not write fixed metadata to \" + metadataFile + \": \" + e.getMessage();\n                if (getLogger().isDebugEnabled()) {\n                    getLogger().warn(msg, e);\n                } else {\n                    getLogger().warn(msg);\n                }\n            }\n        }\n    }\n\n    @Override\n    public void resolveAlways(\n            RepositoryMetadata metadata, ArtifactRepository localRepository, ArtifactRepository remoteRepository)\n            throws RepositoryMetadataResolutionException {\n        File file;\n        try {\n            file = getArtifactMetadataFromDeploymentRepository(metadata, localRepository, remoteRepository);\n        } catch (TransferFailedException e) {\n            throw new RepositoryMetadataResolutionException(\n                    metadata + \" could not be retrieved from repository: \" + remoteRepository.getId()\n                            + \" due to an error: \" + e.getMessage(),","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java#L300-L336","documentation":"Warning from DefaultRepositoryMetadataManager.fixTimestamp: after detecting and correcting a bad lastUpdated timestamp (see the companion warning), Maven tries to persist the repaired Metadata back to disk via MetadataStaxWriter, and the write fails with IOException or XMLStreamException. This branch logs the message WITH the exception because debug is enabled; the corrected state is then lost and the on-disk file keeps its old timestamps.","triggerScenarios":"fixTimestamp wrote to Files.newOutputStream(metadataFile.toPath()) and the OS refused: file or parent directory read-only, no write permission in ~/.m2/repository, disk full, or the StAX writer hit malformed Metadata content. Logged as warn-with-exception under -X.","commonSituations":"Local repository owned by root or another user after running Maven with sudo once; corporate-managed read-only repository caches; disk quota exhausted; antivirus/file locks on Windows.","solutions":["Fix ownership/permissions of the metadata file and its parent directories (chown -R $USER ~/.m2/repository or chmod -R u+w).","Free disk space / raise quota if the write failed with ENOSPC.","Close other processes locking the file (IDE, another build, antivirus) or delete the metadata file so it is recreated.","Re-run with -X and read the attached exception to confirm the exact I/O cause before changing anything."],"exampleFix":"# before\n~/.m2/repository/com/example/... maven-metadata.xml  # read-only, owned by root\n# after\nsudo chown -R $(id -u):$(id -g) ~/.m2/repository\nchmod -R u+w ~/.m2/repository","handlingStrategy":"validation","validationCode":"find ~/.m2/repository ! -writable -o ! -user \"$USER\" | head  # detect unwritable local repo entries","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never run Maven under sudo; fix ownership with chown if already done.","Mount local repository read-write in containers; give the build user write access.","Watch disk space (df -h ~/.m2) on busy CI agents."],"tags":["maven","metadata","io","permissions","write-failure"],"backgroundTag":"metadata-file-write-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}