Reputation: 1023
My local maven repo is here /Users/power/.m2/repository
.
But I got this error
[java] [ERROR] Could not create local repository at /var/root/.m2/repository -> [Help 1]
Seems Maven thinks that it should use a root user repo. How can I fix it? I don't need to run my maven tasks using root permissions.
Upvotes: 11
Views: 59299
Reputation: 132
This error can occur if there is a file called .m2. (Most probably created mistakenly. This happened to me when I copied settings.xml as .m2) If you can delete this and run mvn command again it will create the .m2 folder and you can proceed without a hassel.
Upvotes: 5
Reputation: 71
Deleting the .m2
folder manually helps sometimes
Your .m2
folder might be corrupted and it doesn't permit you to create new or replace existing with new .m2
folder, so delete the existing .m2
folder manually by entering the below commands.
To view the existing .m2
folder
ls -ltra
To Delete it manually
sudo rm .m2
Upvotes: 4
Reputation: 541
The default maven repository is
${user.home}/.m2/repository/
but you can use settings.xml ( ${user.home}/.m2/settings.xml
) to change it to a folder that you have permissions on. Or conf/settings.xml in the ${MAVEN_HOME} and change:
<settings>
...
<localRepository>/path/to/local/repo/</localRepository>
...
</settings>
Ideally, you should run maven as yourself and not root to make sure you have permissions or doing 'ksu' first and then use command line.
Upvotes: 15