Skip to content
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

[Bug]: [Windows] The filename or extension is too long #481

Closed
1 task
akhvatov21 opened this issue Dec 5, 2024 · 4 comments · Fixed by #482
Closed
1 task

[Bug]: [Windows] The filename or extension is too long #481

akhvatov21 opened this issue Dec 5, 2024 · 4 comments · Fixed by #482
Assignees
Labels
bug Something isn't working
Milestone

Comments

@akhvatov21
Copy link

akhvatov21 commented Dec 5, 2024

Brief description

Windows supports only 8191 characters in the command line. It's a known issue. Usually, a plugin that executes some command line codes supports a way to shorten it, for example, using a MANIFEST file

Steps to reproduce

There is no simple way to reproduce it, my project has a lot of protos, including grpc services

[INFO] Generating source code from 440 source files (discovered within 1 source root, from a total of 440 candidate source files)

and the actual command line generated by the plugin is huge

[DEBUG] Protoc invocation will occur with the following arguments:
[DEBUG]     C:\Users\akhvatov\.m2\repository\com\google\protobuf\protoc\4.29.0\protoc-4.29.0-windows-x86_64.exe
[DEBUG]     --java_out=C:\Users\akhvatov\dev\git\client\my-client\my-contract\target\generated-sources\protobuf
[DEBUG]     --plugin=protoc-gen-2Yi2ZTZunOKfQzAuXxckICr72h4=C:\Users\akhvatov\.m2\repository\io\grpc\protoc-gen-grpc-java\1.68.2\protoc-gen-grpc-java-1.68.2-windows-x86_64.exe
[DEBUG]     --2Yi2ZTZunOKfQzAuXxckICr72h4_out=C:\Users\akhvatov\dev\git\client\my-client\my-contract\target\generated-sources\protobuf
[DEBUG]     C:\Users\akhvatov\dev\git\client\my-client\my-contract\src\main\protobuf\proto\file1.proto
[DEBUG]     C:\Users\akhvatov\dev\git\client\my-client\my-contract\src\main\protobuf\proto\file2.proto

basically it has all proto files specified here, probably they are all related, I don't own those files, so can't control them

Error message

Caused by: java.io.IOException: Cannot run program "C:\Users\akhvatov\.m2\repository\com\google\protobuf\protoc\4.29.0\protoc-4.29.0-windows-x86_64.exe": CreateProcess error=206, The filename or extension is too long
    at java.lang.ProcessBuilder.start (ProcessBuilder.java:1170)
    at java.lang.ProcessBuilder.start (ProcessBuilder.java:1089)
    at io.github.ascopes.protobufmavenplugin.protoc.CommandLineExecutor.run (CommandLineExecutor.java:71)
    at io.github.ascopes.protobufmavenplugin.protoc.CommandLineExecutor.execute (CommandLineExecutor.java:60)
    at io.github.ascopes.protobufmavenplugin.generation.ProtobufBuildOrchestrator.generate (ProtobufBuildOrchestrator.java:150)
    at io.github.ascopes.protobufmavenplugin.mojo.AbstractGenerateMojo.execute (AbstractGenerateMojo.java:830)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:41)

Logs

No response

Operating system

Windows 10 22H2

JDK version

21

Maven version

3.9.9

Plugin version

2.7.1

Protoc version

4.29.0

Additional details

No response

Would you like to contribute a bugfix?

  • Yes, I'd like to contribute a bugfix!
@akhvatov21 akhvatov21 added the bug Something isn't working label Dec 5, 2024
@ascopes
Copy link
Owner

ascopes commented Dec 5, 2024

Thanks.

My guess is that the error message is being misleading and the issue is the argline size.

If this is the case, there is a feature in protoc that allows moving these flags to a file instead. I should be able to just swap that out and it should hopefully fix the issue for you.

Will try and find time this weekend.

@ascopes
Copy link
Owner

ascopes commented Dec 7, 2024

Reproduced this in CI...

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.017 s
[INFO] Finished at: 2024-12-07T13:46:32Z
[INFO] ------------------------------------------------------------------------
Error:  Failed to execute goal io.github.ascopes:protobuf-maven-plugin:2.7.2-SNAPSHOT:generate (default) on project gh-481-command-length: Cannot run program "D:\a\protobuf-maven-plugin\protobuf-maven-plugin\protobuf-maven-plugin\target\it-repo\com\google\protobuf\protoc\4.29.0\protoc-4.29.0-windows-x86_64.exe": CreateProcess error=206, The filename or extension is too long -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.github.ascopes:protobuf-maven-plugin:2.7.2-SNAPSHOT:generate (default) on project gh-481-command-length: Cannot run program "D:\a\protobuf-maven-plugin\protobuf-maven-plugin\protobuf-maven-plugin\target\it-repo\com\google\protobuf\protoc\4.29.0\protoc-4.29.0-windows-x86_64.exe": CreateProcess error=206, The filename or extension is too long

Will get a fix out ASAP.

ascopes added a commit that referenced this issue Dec 7, 2024
This change implements the argument file mechanism for protoc
command line flags, like we do already for Java invocations. This
helps avoid build failures on Windows when a large number of files
are being generated, since Windows has somewhat esoteric limits
on the command line length. Offloading this to a file works around
this constraint.
ascopes added a commit that referenced this issue Dec 7, 2024
ascopes added a commit that referenced this issue Dec 7, 2024
@ascopes ascopes closed this as completed in 9949d73 Dec 7, 2024
ascopes added a commit that referenced this issue Dec 7, 2024
ascopes added a commit that referenced this issue Dec 7, 2024
ascopes added a commit that referenced this issue Dec 7, 2024
ascopes added a commit that referenced this issue Dec 7, 2024
ascopes added a commit that referenced this issue Dec 7, 2024
ascopes added a commit that referenced this issue Dec 7, 2024
@ascopes ascopes added this to the v2.7.x milestone Dec 7, 2024
ascopes added a commit that referenced this issue Dec 7, 2024
This irons out some argument file parsing edge cases in protoc for
GH-481
@ascopes
Copy link
Owner

ascopes commented Dec 7, 2024

@akhvatov21
Copy link
Author

@ascopes , thank you very much for the fast fix. I can confirm it works!

ascopes added a commit that referenced this issue Feb 1, 2025
Remove unneeded settings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants