-
Notifications
You must be signed in to change notification settings - Fork 274
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
Version 0.8.4: Cannot compile on Windows when username has a space #212
Comments
On running gradle with --info, it appears that version 0.8.3 executes the following list: whereas version 0.8.4 executes the following string: The following in GenerateProtoTask.groovy appears very suspect:
You cannot just perform string concatenation without at least quoting the protoc path, if the path contains a space. I didn't read the source codes very closely, but I suppose this also affects users of the gRPC plugin. |
Keep the command line as a list of arguments so that spaces in arguments will not be mistaken as argument delimiters. Resolves google#212
Keep the command line as a list of arguments so that spaces in arguments will not be mistaken as argument delimiters. Resolves #212
@yeefan can you check out the head, install the plugin locally with |
@zhangkun83 I checked out the head, and this fixes the problem as far as I am concerned. Thanks a lot. However, looking at your commit, I feel that the following line may not be entirely correct. My understanding is that on Windows, Java ultimately calls the CreateProcess function to execute a command, and this command is a null-terminated C-string. Somewhere along the way, Java must convert the list of strings into the C-string, which means adding quotes whenever an argument contains a space, thus lengthening the command by at least 2. Yet, according to MSDN it may not be as simple as just adding 2 characters, because I didn't check my claim, but I believe there might be a bug in the length computation code. |
The Windows length limits that the plugin currently assumes is 2047 and 8191, which only apply to commands typed in @gegy1000, since you contributed #174, I assume you have a project large enough to trigger the limit issue. Can you try increasing the limits to 30000, which is over the cmd.exe limit but below CreateProcess limit, and see if it still works? |
I experimented with the following Gradle task on Windows Server 2012 trying to find out the Windows limit. task('runcmd') {
doLast {
for (int length = 32768; length >= 0; length--) {
println "Trying length ${length}"
def cmd = []
cmd.add('java')
for (int i = 0; i < length; i++) {
cmd.add('X')
}
try {
def p = cmd.execute()
def stdout = new StringBuffer()
def stderr = new StringBuffer()
p.waitForProcessOutput(stdout, stderr)
println "stdout: ${stdout}, stderr: ${stderr}"
break
} catch (Exception e){}
}
}
} The command was accepted by Windows when |
The CreateProcess limit, not the cmd.exe limit should apply. See google#212 Since there is no difference wrt CreateProcess limit between Windows versions, the related logic is removed.
The CreateProcess limit, not the cmd.exe limit should apply. See #212 Since there is no difference wrt CreateProcess limit between Windows versions, the related logic is removed.
This is now released as 0.8.5 |
Thanks. But 0.8.5 not published on Maven Central? |
Hmm.. I don't know what happened. I just tried again now it shows up. Search index needs more time to be updated, but the artifact is already available. |
Can download the 0.8.5 artifacts now. Thanks again. |
Keep the command line as a list of arguments so that spaces in arguments will not be mistaken as argument delimiters. Resolves google#212
The CreateProcess limit, not the cmd.exe limit should apply. See google#212 Since there is no difference wrt CreateProcess limit between Windows versions, the related logic is removed.
On my computer, my username is "Tan Yee Fan" and hence the path to the Protobuf compiler contains spaces:
When using version 0.8.4 of the plugin, the compilation failed with the following error message:
Downgrading to version 0.8.3 of the plugin resolved the problem.
System information:
The text was updated successfully, but these errors were encountered: