Skip to content

fix: handle long command lines for .bat and .cmd #2035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 1, 2025

Conversation

quintesse
Copy link
Contributor

@quintesse quintesse commented May 28, 2025

On Windows when using Java's ProcessBuilder to run .bat or .cmd files we have to ensure that the command line does not exceed the maximum length allowed by the Windows command line.

Fixes #2033

@quintesse quintesse force-pushed the fix_2033 branch 3 times, most recently from 95730a6 to fd2b5da Compare May 28, 2025 18:04
maxandersen
maxandersen previously approved these changes May 28, 2025
@maxandersen
Copy link
Collaborator

looks good except for the ci failures ;)

@quintesse
Copy link
Contributor Author

looks good except for the ci failures ;)

Yeah yeah :-p

Will you merge or shall I?

On Windows when running command using Java's `ProcessBuilder` to run
.bat or .cmd files we have to ensure that the command line does not
exceed the maximum length allowed by the Windows command line.

Fixes jbangdev#2033
@quintesse
Copy link
Contributor Author

quintesse commented May 30, 2025

Improved the PR by moving the -classpath option for Groovy from the command line to the CLASSPATH env var. It seems that we'd be out of luck if we'd ever hit the 32Kb limit that env vars have on WIndows.

Edit: also, right now the code still isn't perfect. If you are able to add more than 8Kb of source file names then it would still fail. But for now this should fix the most common cases.

The Groovy compiler doesn't handle long command lines well. It supports
`@argfiles` but only for listing source files, not for options. Given the
fact that the longest option tends to be the `-classpath` option, we
can use the `CLASSPATH` environment variable to shorten the command line.
@maxandersen maxandersen merged commit 2aad090 into jbangdev:main Jun 1, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Windows error: The command is too long
2 participants