{"record":{"id":"8263b3b624704c76","repo":"apache/maven","slug":"error-copying-pom-to-the-local-repository","errorCode":null,"errorMessage":"Error copying POM to the local repository.","messagePattern":"Error copying POM to the local repository\\.","errorType":"exception","errorClass":"RepositoryMetadataStoreException","httpStatus":null,"severity":"error","filePath":"compat/maven-compat/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java","lineNumber":83,"sourceCode":"\n    @Override\n    public void storeInLocalRepository(ArtifactRepository localRepository, ArtifactRepository remoteRepository)\n            throws RepositoryMetadataStoreException {\n        File destination = new File(\n                localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata(this, remoteRepository));\n\n        // ----------------------------------------------------------------------------\n        // I'm fully aware that the file could just be moved using File.rename but\n        // there are bugs in various JVM that have problems doing this across\n        // different filesystem. So we'll incur the small hit to actually copy\n        // here and be safe. jvz.\n        // ----------------------------------------------------------------------------\n\n        try {\n            Files.createDirectories(destination.toPath().getParent());\n            Files.copy(file.toPath(), destination.toPath());\n        } catch (IOException e) {\n            throw new RepositoryMetadataStoreException(\"Error copying POM to the local repository.\", e);\n        }\n    }\n\n    @Override\n    public String toString() {\n        return \"project information for \" + artifact.getArtifactId() + \" \" + artifact.getVersion();\n    }\n\n    @Override\n    public boolean storedInArtifactVersionDirectory() {\n        return true;\n    }\n\n    @Override\n    public String getBaseVersion() {\n        return artifact.getBaseVersion();\n    }\n","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java#L65-L101","documentation":"Thrown when ProjectArtifactMetadata (the POM file attached to an installed/deployed artifact) cannot be copied into the local repository during storeInLocalRepository(). The method creates the destination directory and Files.copy's the pom; any IOException is wrapped in RepositoryMetadataStoreException. This is a local filesystem failure, not a network one: unwritable repo, disk full, file locks, or permission problems.","triggerScenarios":"During install of a project, copying the generated pom.xml into ~/.m2/repository/<path>/artifactId-version.pom fails: destination dir cannot be created (permissions), target file locked by another process (Windows AV, concurrent Maven run), disk full, or the local repo moved/unmounted.","commonSituations":"'mvn install' on machines where ~/.m2 is read-only or owned by another user (common in Docker/CI images); two builds writing the same artifact concurrently; antivirus/indexers locking files on Windows; disk quota exhausted on shared CI hosts.","solutions":["Check disk space and quota on the local repository volume (df ~/.m2)","Fix ownership/permissions of the local repo: chown -R $(whoami) ~/.m2/repository or set -Dmaven.repo.local to a writable path","Stop concurrent Maven builds writing the same artifact, or give each build its own local repo","On Windows, exclude ~/.m2 from antivirus scanning or retry after the lock is released","If the repo dir is corrupted (half-written file), delete that artifact's directory and reinstall"],"exampleFix":"# before\ndocker run maven:3 mvn install   # runs as root, repo owned by other uid\n# after\ndocker run -u $(id -u):$(id -g) -v $HOME/.m2:/var/maven/.m2 \\\n  -e MAVEN_CONFIG=/var/maven/.m2 maven:3 mvn install","handlingStrategy":"try-catch","validationCode":"File localRepo = new File(System.getProperty(\"maven.repo.local\", System.getProperty(\"user.home\") + \"/.m2/repository\"));\nif (!localRepo.canWrite() || localRepo.getUsableSpace() < 50L * 1024 * 1024) {\n    fail(\"local repository not writable or low on disk: \" + localRepo);\n}","typeGuard":null,"tryCatchPattern":"try {\n    metadata.storeInLocalRepository(localRepository, remoteRepository);\n} catch (RepositoryMetadataStoreException e) {\n    // filesystem issue: check perms/locks/disk, clean the artifact dir, retry once\n}","preventionTips":["Run builds as the user owning ~/.m2 (fix container uid mapping)","Give concurrent CI builds separate -Dmaven.repo.local directories","Monitor disk space on repo volumes; exclude ~/.m2 from AV scans on Windows"],"tags":["maven","install","local-repository","filesystem","io"],"backgroundTag":"local-repository-write-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}