3

I try to run a mvn install, it compiles fine, but for some reason maven is trying to install to this location:

[INFO] Installing /home/username/workspace/projectname/pom.xml to 
/home/username/workspace/projectname/?/.m2/repository/artifactname/artifact.pom

Note, the location has a ? in it. This location really needs to be the home directory/.m2. Any idea what's causing it to install to the wrong location?

Edit: Executing mvn --help:effective-settings gives:

  <localRepository xmlns="http://maven.apache.org/SETTINGS/1.0.0">
      /home/username/workspace/projectname/?/.m2/repository
  </localRepository>

Interestingly enough, if I run mvn --help:effective-settings from a different directory, say: /tmp, it gives:

  <localRepository xmlns="http://maven.apache.org/SETTINGS/1.0.0">
      /tmp/?/.m2/repository
  </localRepository>
Cuga
  • 17,668
  • 31
  • 111
  • 166
  • Maven has its own ideas about where things belong. This could be its way of telling you to get used to it from the get-go. – erickson Aug 27 '10 at 17:28
  • Why does it install in workspace/projectname at all? Normally its $HOME/.m2 – extraneon Aug 27 '10 at 17:28
  • @extraneon Yes, that's where I want it to go-- $HOME/.m2. I have no idea why it's getting installed to the wrong location. – Cuga Aug 27 '10 at 17:32
  • There is definitely something weird (looks like a global problem). Did things work before? Are you using Maven for the first time with this machine/user? Is this a new environment? – Pascal Thivent Aug 27 '10 at 18:43
  • It is a fresh install of maven for the user. Right now, it works if the user specifies the localRepository in their global settings.xml, but it ignores whatever gets put in the .m2/settings.xml. The crazy part is all the environment variables look fine when she does 'printenv'. – Cuga Aug 27 '10 at 19:12
  • @Cuga Yes, it ignores `~/.m2/settings.xml` because the Java system property `user.home` is currently broken (so the `${user.home}/.m2/settings.xml` won't be found). That's the root cause of all problems and it need to be fixed. – Pascal Thivent Aug 27 '10 at 19:45

3 Answers3

9

Please run the following goal on your project:

mvn help:effective-settings

And check the value of localRepository (and update the question with the value).

Follow-up: Ok, so far, things are coherent. Next...

The default value of localRepository is supposed to be ${user.home}/.m2/repository. Double check that you aren't overriding it in:

  • The settings.xml from the Maven install: $M2_HOME/conf/settings.xml
  • The settings.xml from the user's install: ${user.home}/.m2/settings.xml

If you aren't, check the actual value of ${user.home} (run the following command on your project):

mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=user.home

If you don't get the expected value, check the actual value of %USERPROFILE% if you're on Windows.

Follow-up 2: I'm not sure how ${user.home} gets valued exactly under Linux but this previous question Java: System.getProperty(“user.home”) returns “?” describes the same weird behavior - and a workaround: using a 64-bit JDK on a 64-bit system.

What JDK are you using exactly? On what platform? Could you be in the same situation (in which case, I really think it's a JDK bug, a 32-bit JDK should return the right value on a 64-bit system too).

Follow-up 3: This is actually Bug ID: 6972329 (which is not confirmed as a JDK bug, it could be a system bug).

Community
  • 1
  • 1
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • Thanks, I edited the question to have the output. And tried it from a different location and the value changes. – Cuga Aug 27 '10 at 17:58
  • Running that command (ending in -Dexpression=user.home) returns ? as the output. On linux doing 'echo ~' and 'echo $HOME' both go to the user's correct home: /home/username. This is really bugging me – Cuga Aug 27 '10 at 18:44
  • Since it changes when you change directories I suspect one of your environment variables that affects user.home is set to the current directory "." – Chris Nava Aug 27 '10 at 18:59
  • @Chris: Do you have any advice how we can check if this is the case? – Cuga Aug 27 '10 at 19:13
  • You're exactly right. System.getProperty("user.home"); returns: ? on a 64 bit Fedora 11 running a 32 bit JDK v 1.6.0_21. Thank you so much for the help! – Cuga Aug 27 '10 at 20:55
0

Check out the value of localRepository in settings.xml.

extraneon
  • 23,575
  • 2
  • 47
  • 51
  • I checked-- there's no value set, it should be the default. In fact, I'm rather certain it's not even seeing settings.xml in ~.m2, since it doesn't know to install stuff there. – Cuga Aug 27 '10 at 17:34
  • @Cuga at this point I would be tempted to do a `grep -r -H "workspace/projectname"` on the entire /home/username and see where this is mentioned. Though Pascal's answer is certainly better. – extraneon Aug 27 '10 at 17:47
0

See your environment variables ! Check that you do not have set the "MAVEN_OPTS" variable as that will override all other settings.

I had cut&paste-ed that from another machine not noticing it had : "-Dmaven.repo.local=XXXX" in it. (blush)

user3852017
  • 190
  • 1
  • 9