Skip to content

How to uninstall Maven on a Mac, and its local repository

Remove Maven with Homebrew or from its unpacked folder, and the ~/.m2 repository of downloaded libraries, which is usually larger than Maven.

4 min read

How do I uninstall Maven on a Mac?

brew uninstall maven for Homebrew. Ours, version 3.9.11, was 10 MB. If you unpacked it by hand, remove that folder and the M2_HOME or PATH lines in ~/.zshrc.

What is the .m2 folder?

~/.m2/repository is Maven's local copy of every library any project downloaded. Ours was 44 MB; on a Mac that has built a few large projects it is often several gigabytes. ~/.m2/settings.xml holds your settings, including any repository passwords, so check it before deleting.

More: Maven's repository taking up space and uninstall Gradle.

Common questions

How do I uninstall Maven on Mac?

Run brew uninstall maven, or delete the folder you unpacked, then remove its PATH lines from ~/.zshrc.

Can I delete the .m2 folder?

The repository inside it, yes: Maven downloads again what it needs. Keep settings.xml if you use it.

Read next