Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Task throws error=7: Argument list too long

Tags:

shell

ant

I have an Ant's build.xml file which executes with no problems on my machine (Ubuntu), but throws the following error:

/var/lib/hudson/workspace/myproject/build.xml:254: Error running /var/lib/hudson/tools/java_6/bin/javac compiler
at org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.executeExternalCompile(DefaultCompilerAdapter.java:525)
(...)
Caused by: java.io.IOException: Cannot run program "/var/lib/hudson/tools/java_6/bin/javac": java.io.IOException: error=7, Argument list too long
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at java.lang.Runtime.exec(Runtime.java:593)
at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.java:862)
at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:481)
at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:495)
at org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.executeExternalCompile(DefaultCompilerAdapter.java:522)
... 19 more
Caused by: java.io.IOException: java.io.IOException: error=7, Argument list too long
at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 24 more

The argument list is quite big in fact contains all the jar files from WEB-INF/lib which is 231650 characters long! Any suggestions how to fix it?

like image 941
lrkwz Avatar asked Nov 05 '22 00:11

lrkwz


1 Answers

With a command that long you are likely running in to ARG_MAX at the shell.

This will report a good estimate of the available length, expr getconf ARG_MAX - env|wc -c - env|wc -l * 4 - 2048

A nice article about command arg lists and length can be found here

like image 154
Bill N. Avatar answered Nov 10 '22 04:11

Bill N.