5

I've inherited a machine from another person, and maven thinks I'm a different user. This is me:

C:\> echo %USERPROFILE%
C:\Users\awesomeuser

Although maven thinks I'm administrator and fails to create the .m2 folder there.

[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from c:\apps\tools\apache-maven-3.1.0\bin\..\conf\settings.xml
[DEBUG] Reading user settings from C:\Users\Administrator\.m2\settings.xml
[DEBUG] Using local repository at C:\Users\Administrator\.m2\repository
[ERROR] Could not create local repository at C:\Users\Administrator\.m2\repository -> [Help 1]
org.apache.maven.repository.LocalRepositoryNotAccessibleException: Could not create local repository at C:\Users\Administrator\.m2\repository

Any ideas how to get maven to recognize I'm awesomeuser not Administrator?

stuff22
  • 1,662
  • 4
  • 24
  • 42

2 Answers2

3

I'm not sure what environmental variable is causing Maven to look at the wrong home directory.

However, you can set per execution with -s or --settings option to control where to look for the settings.xml.

Alternatively you can set it globally by updating m2.conf in your \bin directory. It sets the default user home.

EDIT:

I did some more research and Maven uses the Java property user.home. It looks like sometimes it can be wrong and not match your user profile.

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4787931

JustinKSU
  • 4,875
  • 2
  • 29
  • 51
  • I'm more interested in having it go to my user directory by default. I don't want to manually override this every time. – stuff22 Nov 25 '13 at 17:11
  • Have you tried typing "set" and seeing if there are any variables set to the Administrator's home? – JustinKSU Nov 25 '13 at 17:19
  • Updated answer with another alternative. – JustinKSU Nov 25 '13 at 17:21
  • Yes. did all that. Turns out that my problem is more of this nature: http://stackoverflow.com/a/2134775/237925. I have tons of references to C:\Users\Administrator in the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders – stuff22 Nov 25 '13 at 17:49
  • This answer is fuller (the second alternative about `user.home`). That linked bug explains why regedit hack in @stuff22's answer works. Basically this happens if windows home dir is changed some time after the creation of user account. – Incassator May 06 '15 at 22:37
2

Turns out that my problem is more of this nature: https://stackoverflow.com/a/2134775/237925. I have tons of references to C:\Users\Administrator in the

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

Community
  • 1
  • 1
stuff22
  • 1,662
  • 4
  • 24
  • 42