72

I cant seem to find the local .m2 folder on Mac OS X mavericks. Ideally it should be at {user.home}/.m2 but I cant seem to find it.

Should I create it?

seeker
  • 6,841
  • 24
  • 64
  • 100

10 Answers10

73

If you have used brew to install maven, create .m2 directory and then copy settings.xml in .m2 directory.

mkdir ~/.m2
cp /usr/local/Cellar/maven32/3.2.5/libexec/conf/settings.xml ~/.m2

You may need to change the maven version in the path, mine is 3.2.5

Tenzin Chemi
  • 5,101
  • 2
  • 27
  • 33
38

On the top of the screen you can find the Finder. Click Go -> Go to Folder -> search ~/.m2

If it is not found, as m2 is a hidden file you need to enable visibility by typing the following command in terminal:

defaults write com.apple.finder AppleShowAllFiles YES

robinCTS
  • 5,746
  • 14
  • 30
  • 37
Sachin Poreyana
  • 1,947
  • 15
  • 12
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/17979006) – Nigam Patro Nov 17 '17 at 11:57
  • 8
    @NigamPatro Actually, it *does* answer the question. It answers the title "Where is my m2 folder on Mac OS X Mavericks" (as well as the implicit question in the body of the post) by showing *how* to find it, just like two of the other answers. It also implicitly answers the question "Should I create it?", i.e. -> if you can't find it by doing a proper search for it, then it doesn't exist, and if you need it then by all means create it! – robinCTS Nov 18 '17 at 05:08
  • 9
    If you can't see hidden files in MAC's Finder, simply press SHIFT + CMD + . (dot) – Piotr Kowalski May 07 '21 at 12:31
31

Go to finder:

Press on keyboard CMD+shift+G . it will show u a popup like this

Enter path ~/.m2

press enter.

Rohit Kumar
  • 983
  • 9
  • 11
17

It's in your home folder but it's hidden by default.

Typing the below commands in the terminal made it visible for me (only the .m2 folder that is, not all the other hidden folders).

> mv ~/.m2 ~/m2
> ln -s ~/m2 ~/.m2         

Source

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
Robin
  • 171
  • 2
  • 2
    Does this not just instead move default-hidden ~/.m2 to visible ~/m2? If so, this isn't the same as making the former ~/.m2 visible. – cellepo Nov 07 '20 at 05:06
12

If you search directly it won't appear so please follow as below steps to see .M2 repository path.

Go-> Find folder ->  type this "~/.m2" and click go

If Maven is already installed and used, the .m2 will be listed.

Source

Anatole ABE
  • 575
  • 1
  • 7
  • 12
8

By default it will be hidden in your home directory. Type ls -a ~ to view that.

rakesh
  • 4,368
  • 1
  • 19
  • 13
8

On mac just run mvn clean install assuming maven has been installed and it will create .m2 automatically.

vimal krishna
  • 2,886
  • 28
  • 22
  • I was looking for this option as I didnt want to create a folder manually and probably run into the issues of setting access for users and groups using chmod. – Spear A1 Apr 18 '19 at 03:30
7

You can try searching for local .m2 repository by using the command in the project directory.

mvn help:evaluate -Dexpression=settings.localRepository

your output will be similar to below and you can see local .m2 directory path as shown below: /Users/arai/.m2/repository

Downloading from central: https://repo.maven.apache.org/maven2/org/apache/commons/commons-lang3/3.7/commons-lang3-3.7.jar
Downloaded from central: https://repo.maven.apache.org/maven2/net/sf/jtidy/jtidy/r938/jtidy-r938.jar (250 kB at 438 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/commons-codec/commons-codec/1.11/commons-codec-1.11.jar (335 kB at 530 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/jdom/jdom2/2.0.6/jdom2-2.0.6.jar (305 kB at 430 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/commons/commons-lang3/3.7/commons-lang3-3.7.jar (500 kB at 595 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/com/thoughtworks/xstream/xstream/1.4.11.1/xstream-1.4.11.1.jar (621 kB at 671 kB/s)
[INFO] No artifact parameter specified, using 'org.apache.maven:standalone-pom:pom:1' as project.
[INFO]
/Users/arai/.m2/repository
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.540 s
[INFO] Finished at: 2019-01-23T13:57:54-05:00
[INFO] ------------------------------------------------------------------------
Durja
  • 637
  • 13
  • 20
3

Go to your root folder

Shift + Command + .

press this then you can see all the hidden files. Because your .m2 file suppose to be a hidden folder

Dinithi
  • 518
  • 5
  • 17
3
  1. Open your terminal
  2. Type open ~/.m2

It will open .m2 folder in explorer

Vijay Shegokar
  • 2,492
  • 1
  • 20
  • 30
Sneha Mule
  • 641
  • 8
  • 6