1

I am trying to build hadoop from source as explained in this article. When building Apache common, everything fails with this error message: command line too long.

So, Here's what I have tried(I will update this when I try more):

  1. As said in this Stackoverflow answer, the way to overcome this error is to shorten the path as much as possible. So, I cut repository files from C:\user_name\.m2\repository\ to another directory and made an empty drive and have that point to this new directory which i have moved files to, like this subst M: D:\maven-2.0.8\repository and changed <localRepository>M:</localRepository> tag in "settings.xml" from C:\apache-maven-2.0.8\conf to point to M:. And after doing all this, I restart my system and try to build hadoop again. But, as I can see from the error, maven still downloads packages to C:\Users\user_name\.m2\repository\, not M: and the error of command line too long error persists.
  2. To shorten the path as much as possible, i made a directory in C:\mrepo and have this directory symbolically link to the C:\user_name\.m2\repository\ like this: mklink /J C:\mrepo C:\Users\.m2\repository. And after doing all this, I restart my system and try to build hadoop again. But, as I can see from the error, maven still downloads packages to C:\Users\user_name\.m2\repository\, not M: and the error of command line too long error persists.

EDIT 1:

  1. I have also set an environment variable named M2_HOME with value M:\. And made changes in my \conf\settings.xml: <localRepository>${M2_HOME}</localRepository>. The issue still persisits.

How do I fix this and build hadoop successfully?

Community
  • 1
  • 1
  • Good question. You reference another SO post, so you clearly tried to find out how to fix it on your own. The only thing missing is what operating system you're using, though I infer from the post it's some form of Windows. – David Nedrow May 16 '20 at 00:42
  • 1
    Question's title has it. It's windows 10. – Naveen Reddy Marthala May 16 '20 at 01:38
  • Does you build run on plain windows command line? – khmarbaise May 16 '20 at 11:29
  • @khmarbaise I did all of this on "visual studio x64 win64 commands prompt", which i presume is windows command line. –  May 16 '20 at 11:51
  • So the answer to this is: No. I don't know Visual Studio nor do I use it...so the first test is always test on plain command line to remove any influence which could happen... – khmarbaise May 16 '20 at 11:53

2 Answers2

0

Are you using IntelliJ?

Because in IntelliJ you have some options to shorten your command line. Go to Run/Debug Configurations. Shorten command line, you can try the classpath file option.

You can find more information about it in this blog post.

  • No, I'm not using any IDE. I am doing this on visual studio x64 command prompt. –  May 16 '20 at 01:45
0

If you want to set the .m2 directory to something explicit, you do can so by overriding the default.

  • All Users: Edit the \conf\settings.xml global configuration file. Change the value of the localRepository key to the absolute path of the local repository cache.

  • Your user: I think you should be able to set the M2_HOME environment variable in your user settings.

David Nedrow
  • 1,098
  • 1
  • 9
  • 26
  • I couldn't understand what you meant by "to the absolute path of the local repository cache." And i have set `M2_Home` variable too, to the directory to which i have moved repository (files from `\..\user_name\.m2\repository\`) files to. –  May 16 '20 at 01:52
  • `M2_Home` or `M2_HOME`? I don't know if it makes a difference, but it should be all uppercase. `Absolute path`s are enumerated from the root of the drive. For Windows, something like `C:\M2_HOME`. Are you using the command prompt in Visual Studio, or are you using the PowerShell prompt in Visual Studio? The former will inherit you system and user environment variables, but it would appear that PowerShell does not, which makes sense. – David Nedrow May 18 '20 at 01:15
  • I have used `M2_HOME`. And I have used command prompt in visual studio. –  May 18 '20 at 05:55