My local maven repo is here /Users/power/.m2/repository
.
But I got this error
[java] [ERROR] Could not create local repository at /var/
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
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.
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.