apache/maven · error · RepositoryMetadataStoreException
Error copying POM to the local repository.
Error message
Error copying POM to the local repository.
What it means
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.
Source
Thrown at compat/maven-compat/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java:83
@Override
public void storeInLocalRepository(ArtifactRepository localRepository, ArtifactRepository remoteRepository)
throws RepositoryMetadataStoreException {
File destination = new File(
localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata(this, remoteRepository));
// ----------------------------------------------------------------------------
// I'm fully aware that the file could just be moved using File.rename but
// there are bugs in various JVM that have problems doing this across
// different filesystem. So we'll incur the small hit to actually copy
// here and be safe. jvz.
// ----------------------------------------------------------------------------
try {
Files.createDirectories(destination.toPath().getParent());
Files.copy(file.toPath(), destination.toPath());
} catch (IOException e) {
throw new RepositoryMetadataStoreException("Error copying POM to the local repository.", e);
}
}
@Override
public String toString() {
return "project information for " + artifact.getArtifactId() + " " + artifact.getVersion();
}
@Override
public boolean storedInArtifactVersionDirectory() {
return true;
}
@Override
public String getBaseVersion() {
return artifact.getBaseVersion();
}
View on GitHub (pinned to e4093d4e12)
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
Example fix
# before docker run maven:3 mvn install # runs as root, repo owned by other uid # after docker run -u $(id -u):$(id -g) -v $HOME/.m2:/var/maven/.m2 \ -e MAVEN_CONFIG=/var/maven/.m2 maven:3 mvn install
Defensive patterns
Strategy: try-catch
Validate before calling
File localRepo = new File(System.getProperty("maven.repo.local", System.getProperty("user.home") + "/.m2/repository"));
if (!localRepo.canWrite() || localRepo.getUsableSpace() < 50L * 1024 * 1024) {
fail("local repository not writable or low on disk: " + localRepo);
} Try / catch
try {
metadata.storeInLocalRepository(localRepository, remoteRepository);
} catch (RepositoryMetadataStoreException e) {
// filesystem issue: check perms/locks/disk, clean the artifact dir, retry once
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: '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.
Related errors
- Could not create local repository at {}
- Cannot read module information.
- Range defies version ordering: {}
- Cannot read metadata from '{}': {}
- Error installing metadata: {}
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/8263b3b624704c76.
Report an issue: GitHub.