Skip to content

Can't write to /var/maven it not root user #332

@zachradtka

Description

@zachradtka

Similar close issues re #86 and #83 .

My docker command is copied directly from the example:

docker run -v ~/.m2:/var/maven/.m2 -it --rm -u $(id -u) -e MAVEN_CONFIG=/var/maven/.m2 maven mvn -e -Duser.home=/var/maven archetype:generate

The output is:

mkdir: cannot create directory ‘/var/maven/.m2/repository’: Permission denied
Can not write to /var/maven/.m2/copy_reference_file.log. Wrong volume permissions? Carrying on ...
[INFO] Error stacktraces are turned on.
[ERROR] Could not create local repository at /var/maven/.m2/repository -> [Help 1]
org.apache.maven.repository.LocalRepositoryNotAccessibleException: Could not create local repository at /var/maven/.m2/repository
    at org.apache.maven.DefaultMaven.validateLocalRepository (DefaultMaven.java:385)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:169)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LocalRepositoryNotAccessibleException

My ~/.m2 directory is owned by my user:

ls -alhn ~/.m2
total 8.0K
drwxr-xr-x  2 1000 1000 4.0K Feb 13 16:43 .
drwxr-xr-x 57 1000 1000 4.0K Feb 13 16:42 ..

I am running Ubuntu on WSL2.

Please let me know if there is anymore information that might be helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions