tags:

views:

84

answers:

2

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"&gt;
      /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"&gt;
      /tmp/?/.m2/repository
  </localRepository>
A: 

Check out the value of localRepository in settings.xml.

extraneon
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
@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
+4  A: 

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).

Pascal Thivent
Thanks, I edited the question to have the output. And tried it from a different location and the value changes.
Cuga
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
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
@Chris: Do you have any advice how we can check if this is the case?
Cuga
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