Skip to content

Windows error: The command is too long #2033

Closed
@wfouche

Description

@wfouche

Describe the bug
When running a Kotlin script which references many JAR files, the compile steps fails with error "The command is too long".

To Reproduce

[jbang] [1:211] Building jar for App.kt...
[jbang] [1:213] Compile: C:\Users\wfouche\.jbang\cache\kotlincs\2.0.21\kotlinc\bin\kotlinc.bat 
-progressive -classpath C:\Users\wfouche\.m2\repository\io\github\wfouche\tulip\tulip-runtime\2.1.8-dev\tulip-runtime-2.1.8-dev.jar;C:\Users\wfouche\.m2\repository\org\hdrhistogram\HdrHistogram\2.2.2\HdrHistogram-2.2.2.jar;C:\Users\wfouche\.m2\repository\org\python\jython-slim\2.7.4\jython-slim-2.7.4.jar;C:\Users\wfouche\.m2\repository\org\antlr\antlr\3.5.3\antlr-3.5.3.jar;C:\Users\wfouche\.m2\repository\org\antlr\ST4\4.3.1\ST4-4.3.1.jar;C:\Users\wfouche\.m2\repository\javax\servlet\javax.servlet-api\3.1.0\javax.servlet-api-3.1.0.jar;C:\Users\wfouche\.m2\repository\org\antlr\antlr-runtime\3.5.3\antlr-runtime-3.5.3.jar;C:\Users\wfouche\.m2\repository\org\apache\commons\commons-compress\1.26.2\commons-compress-1.26.2.jar;C:\Users\wfouche\.m2\repository\commons-codec\commons-codec\1.17.0\commons-codec-1.17.0.jar;C:\Users\wfouche\.m2\repository\org\apache\commons\commons-lang3\3.14.0\commons-lang3-3.14.0.jar;C:\Users\wfouche\.m2\repository\commons-io\commons-io\2.16.1\commons-io-2.16.1.jar;C:\Users\wfouche\.m2\repository\org\bouncycastle\bcpkix-jdk18on\1.78.1\bcpkix-jdk18on-1.78.1.jar;C:\Users\wfouche\.m2\repository\org\bouncycastle\bcutil-jdk18on\1.78.1\bcutil-jdk18on-1.78.1.jar;C:\Users\wfouche\.m2\repository\org\bouncycastle\bcprov-jdk18on\1.78.1\bcprov-jdk18on-1.78.1.jar;C:\Users\wfouche\.m2\repository\org\ow2\asm\asm\9.7\asm-9.7.jar;C:\Users\wfouche\.m2\repository\org\ow2\asm\asm-commons\9.7\asm-commons-9.7.jar;C:\Users\wfouche\.m2\repository\org\ow2\asm\asm-tree\9.7\asm-tree-9.7.jar;C:\Users\wfouche\.m2\repository\org\ow2\asm\asm-util\9.7\asm-util-9.7.jar;C:\Users\wfouche\.m2\repository\org\ow2\asm\asm-analysis\9.7\asm-analysis-9.7.jar;C:\Users\wfouche\.m2\repository\com\google\guava\guava\33.2.1-jre\guava-33.2.1-jre.jar;C:\Users\wfouche\.m2\repository\com\google\guava\failureaccess\1.0.2\failureaccess-1.0.2.jar;C:\Users\wfouche\.m2\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;C:\Users\wfouche\.m2\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;C:\Users\wfouche\.m2\repository\org\checkerframework\checker-qual\3.42.0\checker-qual-3.42.0.jar;C:\Users\wfouche\.m2\repository\com\google\j2objc\j2objc-annotations\3.0.0\j2objc-annotations-3.0.0.jar;C:\Users\wfouche\.m2\repository\com\ibm\icu\icu4j\75.1\icu4j-75.1.jar;C:\Users\wfouche\.m2\repository\com\carrotsearch\java-sizeof\0.0.5\java-sizeof-0.0.5.jar;C:\Users\wfouche\.m2\repository\com\github\jnr\jffi\1.3.13\jffi-1.3.13.jar;C:\Users\wfouche\.m2\repository\com\github\jnr\jnr-constants\0.10.4\jnr-constants-0.10.4.jar;C:\Users\wfouche\.m2\repository\com\github\jnr\jnr-ffi\2.2.16\jnr-ffi-2.2.16.jar;C:\Users\wfouche\.m2\repository\com\github\jnr\jffi\1.3.13\jffi-1.3.13-native.jar;C:\Users\wfouche\.m2\repository\com\github\jnr\jnr-a64asm\1.0.0\jnr-a64asm-1.0.0.jar;C:\Users\wfouche\.m2\repository\com\github\jnr\jnr-x86asm\1.0.2\jnr-x86asm-1.0.2.jar;C:\Users\wfouche\.m2\repository\com\github\jnr\jnr-netdb\1.2.0\jnr-netdb-1.2.0.jar;C:\Users\wfouche\.m2\repository\com\github\jnr\jnr-posix\3.1.19\jnr-posix-3.1.19.jar;C:\Users\wfouche\.m2\repository\jline\jline\2.14.6\jline-2.14.6.jar;C:\Users\wfouche\.m2\repository\io\netty\netty-buffer\4.1.73.Final\netty-buffer-4.1.73.Final.jar;C:\Users\wfouche\.m2\repository\io\netty\netty-codec\4.1.73.Final\netty-codec-4.1.73.Final.jar;C:\Users\wfouche\.m2\repository\io\netty\netty-common\4.1.73.Final\netty-common-4.1.73.Final.jar;C:\Users\wfouche\.m2\repository\io\netty\netty-handler\4.1.73.Final\netty-handler-4.1.73.Final.jar;C:\Users\wfouche\.m2\repository\io\netty\netty-tcnative-classes\2.0.46.Final\netty-tcnative-classes-2.0.46.Final.jar;C:\Users\wfouche\.m2\repository\io\netty\netty-resolver\4.1.73.Final\netty-resolver-4.1.73.Final.jar;C:\Users\wfouche\.m2\repository\io\netty\netty-transport\4.1.73.Final\netty-transport-4.1.73.Final.jar;C:\Users\wfouche\.m2\repository\org\apache\ant\ant\1.10.14\ant-1.10.14.jar;C:\Users\wfouche\.m2\repository\org\apache\ant\ant-launcher\1.10.14\ant-launcher-1.10.14.jar;C:\Users\wfouche\.m2\repository\org\jetbrains\kotlinx\kotlinx-serialization-json-jvm\1.8.1\kotlinx-serialization-json-jvm-1.8.1.jar;C:\Users\wfouche\.m2\repository\org\jetbrains\kotlinx\kotlinx-serialization-core-jvm\1.8.1\kotlinx-serialization-core-jvm-1.8.1.jar;C:\Users\wfouche\.m2\repository\io\leego\banana\2.1.0\banana-2.1.0.jar;C:\Users\wfouche\.m2\repository\com\google\code\gson\gson\2.13.1\gson-2.13.1.jar;C:\Users\wfouche\.m2\repository\com\google\errorprone\error_prone_annotations\2.38.0\error_prone_annotations-2.38.0.jar;C:\Users\wfouche\.m2\repository\org\apache\httpcomponents\client5\httpclient5\5.5\httpclient5-5.5.jar;C:\Users\wfouche\.m2\repository\org\apache\httpcomponents\core5\httpcore5\5.3.4\httpcore5-5.3.4.jar;C:\Users\wfouche\.m2\repository\org\apache\httpcomponents\core5\httpcore5-h2\5.3.4\httpcore5-h2-5.3.4.jar;C:\Users\wfouche\.m2\repository\org\springframework\boot\spring-boot-starter-web\3.4.4\spring-boot-starter-web-3.4.4.jar;C:\Users\wfouche\.m2\repository\org\springframework\boot\spring-boot-starter\3.4.4\spring-boot-starter-3.4.4.jar;C:\Users\wfouche\.m2\repository\org\springframework\boot\spring-boot\3.4.4\spring-boot-3.4.4.jar;C:\Users\wfouche\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\3.4.4\spring-boot-autoconfigure-3.4.4.jar;C:\Users\wfouche\.m2\repository\org\springframework\boot\spring-boot-starter-logging\3.4.4\spring-boot-starter-logging-3.4.4.jar;C:\Users\wfouche\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.24.3\log4j-to-slf4j-2.24.3.jar;C:\Users\wfouche\.m2\repository\org\apache\logging\log4j\log4j-api\2.24.3\log4j-api-2.24.3.jar;C:\Users\wfouche\.m2\repository\org\slf4j\jul-to-slf4j\2.0.17\jul-to-slf4j-2.0.17.jar;C:\Users\wfouche\.m2\repository\jakarta\annotation\jakarta.annotation-api\2.1.1\jakarta.annotation-api-2.1.1.jar;C:\Users\wfouche\.m2\repository\org\springframework\spring-core\6.2.5\spring-core-6.2.5.jar;C:\Users\wfouche\.m2\repository\org\springframework\spring-jcl\6.2.5\spring-jcl-6.2.5.jar;C:\Users\wfouche\.m2\repository\org\yaml\snakeyaml\2.3\snakeyaml-2.3.jar;C:\Users\wfouche\.m2\repository\org\springframework\boot\spring-boot-starter-json\3.4.4\spring-boot-starter-json-3.4.4.jar;C:\Users\wfouche\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.18.3\jackson-databind-2.18.3.jar;C:\Users\wfouche\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.18.3\jackson-annotations-2.18.3.jar;C:\Users\wfouche\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.18.3\jackson-core-2.18.3.jar;C:\Users\wfouche\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.18.3\jackson-datatype-jdk8-2.18.3.jar;C:\Users\wfouche\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.18.3\jackson-datatype-jsr310-2.18.3.jar;C:\Users\wfouche\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.18.3\jackson-module-parameter-names-2.18.3.jar;C:\Users\wfouche\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\3.4.4\spring-boot-starter-tomcat-3.4.4.jar;C:\Users\wfouche\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\10.1.39\tomcat-embed-core-10.1.39.jar;C:\Users\wfouche\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\10.1.39\tomcat-embed-el-10.1.39.jar;C:\Users\wfouche\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\10.1.39\tomcat-embed-websocket-10.1.39.jar;C:\Users\wfouche\.m2\repository\org\springframework\spring-web\6.2.5\spring-web-6.2.5.jar;C:\Users\wfouche\.m2\repository\org\springframework\spring-beans\6.2.5\spring-beans-6.2.5.jar;C:\Users\wfouche\.m2\repository\io\micrometer\micrometer-observation\1.14.5\micrometer-observation-1.14.5.jar;C:\Users\wfouche\.m2\repository\io\micrometer\micrometer-commons\1.14.5\micrometer-commons-1.14.5.jar;C:\Users\wfouche\.m2\repository\org\springframework\spring-webmvc\6.2.5\spring-webmvc-6.2.5.jar;C:\Users\wfouche\.m2\repository\org\springframework\spring-aop\6.2.5\spring-aop-6.2.5.jar;C:\Users\wfouche\.m2\repository\org\springframework\spring-context\6.2.5\spring-context-6.2.5.jar;C:\Users\wfouche\.m2\repository\org\springframework\spring-expression\6.2.5\spring-expression-6.2.5.jar;C:\Users\wfouche\.m2\repository\org\slf4j\slf4j-api\2.0.17\slf4j-api-2.0.17.jar;C:\Users\wfouche\.m2\repository\ch\qos\logback\logback-core\1.5.18\logback-core-1.5.18.jar;C:\Users\wfouche\.m2\repository\ch\qos\logback\logback-classic\1.5.18\logback-classic-1.5.18.jar;C:\Users\wfouche\.m2\repository\org\jetbrains\kotlin\kotlin-stdlib\2.0.21\kotlin-stdlib-2.0.21.jar;C:\Users\wfouche\.m2\repository\org\jetbrains\annotations\13.0\annotations-13.0.jar -d C:\Users\wfouche\.jbang\cache\jars\App.kt.a277408206e614ae2c4ca01f8f5ad3599827a155411d19254e7ea0bcb4a6c436\classes C:\Users\wfouche\IdeaProjects\jbang-catalog\temp\io\tulip\App.kt C:\Users\wfouche\IdeaProjects\jbang-catalog\temp\io\tulip\HttpUser.kt
The command line is too long.
[jbang] [2025-05-26 18:35:27] ProcessBuilder.start(): pid: 16452, dir: null, cmd: "C:\Users\wfouche\.jbang\cache\kotlincs\2.0.21\kotlinc\bin\kotlinc.bat"
[jbang] [1:237] Deleting folder C:\Users\wfouche\.jbang\cache\jars\App.kt.a277408206e614ae2c4ca01f8f5ad3599827a155411d19254e7ea0bcb4a6c436\classes
[jbang] [1:243] Deleting folder C:\Users\wfouche\.jbang\cache\jars\App.kt.a277408206e614ae2c4ca01f8f5ad3599827a155411d19254e7ea0bcb4a6c436\generated
[jbang] [1:244] [ERROR] Error during compile
dev.jbang.cli.ExitException: Error during compile
        at dev.jbang.source.buildsteps.CompileBuildStep.runCompiler(CompileBuildStep.java:151)
        at dev.jbang.source.buildsteps.CompileBuildStep.runCompiler(CompileBuildStep.java:135)
        at dev.jbang.source.buildsteps.CompileBuildStep.compile(CompileBuildStep.java:119)
        at dev.jbang.source.buildsteps.CompileBuildStep.build(CompileBuildStep.java:56)
        at dev.jbang.source.buildsteps.CompileBuildStep.build(CompileBuildStep.java:41)
        at dev.jbang.source.AppBuilder.build(AppBuilder.java:97)
        at dev.jbang.source.AppBuilder.build(AppBuilder.java:22)
        at dev.jbang.cli.Run.doCall(Run.java:88)
        at dev.jbang.cli.BaseCommand.call(BaseCommand.java:145)
        at dev.jbang.cli.BaseCommand.call(BaseCommand.java:21)
        at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
        at picocli.CommandLine.access$1500(CommandLine.java:148)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
        at dev.jbang.cli.JBang$3.handle(JBang.java:150)
        at dev.jbang.cli.JBang$3.handle(JBang.java:145)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
        at picocli.CommandLine.execute(CommandLine.java:2170)
        at dev.jbang.Main.main(Main.java:23)
[jbang] [1:247] If you believe this a bug in jbang, open an issue at https://github.com/jbangdev/jbang/issues
[jbang] [2025-05-26 18:35:28] Runtime.exit() called with status: 1

Expected behavior
This is a known issue in the world of Windows. IntelliJ has a workaround that can be enabled which saves all the command arguments and long classpath to a text file which is than passed to a program as "program.exe @arguments.txt"

JBang version
0.126.1

Additional context
I don't think this is Kotlin specific and the same error can potentially occurr with Java, or Groovy scripts.
java.exe and javac.exe support the shortened comand-line @arguments.txt convention. kotlinc.bat supports it as well.

java:

  • @argument files - One or more argument files containing options

javac:

  • @<filename> - Read options and filenames from file
    kotlinc:

  • @<argfile> - Read compiler arguments and file paths from the given file.

Intellij shortened command-line

Proposed Solution

Modify JBang to always use an @arguments file when starting Windows processes.

For example , invoke the Kotlin compiler as:

....\kotlincs\2.0.21\kotlinc\bin\kotlinc.bat @arguments.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions