Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zachradtka opened this issue Feb 13, 2023 · 2 comments
Open

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

zachradtka opened this issue Feb 13, 2023 · 2 comments

Comments

@zachradtka
Copy link

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.

@carlossg
Copy link
Owner

Probably some issue with how permissions work on WSL2, I bet if you chmod 777 ~/.m2 before running docker it works

@zachradtka
Copy link
Author

Thanks for the prompt reply.

I tried changing permissions and still the same error. Here is my m2 directory with 777.

$ ls -lad ~/.m2
drwxrwxrwx 3 zach zach 4096 Feb 13 17:04 /home/zach/.m2

Here is the same error as before.

$ 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
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

I am not entirely sure, but I feel like it's a permission problem within the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants