-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Mitigate long classpath on Windows for JavaExec #10114
Comments
Possible SolutionsSolution 1: Modify JavaExecHandleBuilder to always pass all argument as arg file (JDK 9+)Pro
Con
Note
Solution 2: Modify JavaExecHandleBuilder to always pass only the classpath as arg file (JDK 9+)Pro
Con
Note
Solution 3: Modify JavaExecHandleBuilder as noted in the previous solutions but only for Windows (JDK 9+)Pro
Con
Solution 4: Modify JavaExecHandleBuilder as noted in the previous solution but enable through a flag (JDK 9+)Pro
Con
Solution 5: Provide methods to compose the intended behaviourProvide a method like Pro
Con
Solution 6: Use Windows long path notation (e.g.
|
Possible DSLs could look like this: Use arg file or pathing Jar for classpathAs a flag:
or, as a composable method
Modeling arg file
|
@lacasseio FYI Eclipse JDT has a few tricks to shorten the classpath, some of which work with older Java versions: https://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/tree/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/ClasspathShortener.java |
I think the best solution is to change the behavior only on Windows and change the classpath only if it's too long (to prevent performance issues when the classpath is not that long). Also, why do we need to change the DSL? Can't we just convert the long classpaths (to a classpath-only jar for instance) behind the scenes when necessary? |
It may have some impact and I guess some users may not want the "new default" we would be pushing. It would be good if there was a way to disable it if they prefer another way to shorten the classpath. |
+1 for doing this transparently. I think this should work for any version of Java we would support via I would open this up to not just too long of a classpath, but too long of a command-line, since it would manifest itself as the same sort of problem and we need to know if the full command-line is too long and not just the classpath. It looks like even Linux/macOS have limits: https://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/tree/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/ClasspathShortener.java#n267 So some increments could be...
I think this limits the changes to only builds where the java command would have failed already. I think this should be done in a cross-cutting way so all forked Java executions take advantage of this change, but it's out of scope to try to fix this in the Scala/Groovy/Kotlin compilers (if they're forking java). Here's another source to pull inspiration from: https://github.com/microsoft/vscode-java-debug/pull/532/files |
Then here is what I propose as the next steps:
|
@big-guy On OS where we don't know the limit, should we assume the most restrictive known limit? |
Actually, I will scope the usage of the environment variable in and use that first before the pathing Jar, the side effect of the pathing Jar is quite troublesome for the users. |
Recently, I started developing a new Grails web application using the newly released Grails 4.0.0, which depends on Gradle 5.1.1. When I added the Elasticsearch 2.4.2 dependency, I ran into the issue: I have searched and tried several workarounds offered by many, but all has failed so far, with Grails 4, Grade 5 and JDK 8 on Win10 (IntelliJ). Is there a possible temporary workaround for the stack / environments that I am using, while we wait for this issue to get resolved? |
A better error message detection will be provided for Windows in Gradle 6.0. We are rolling out command line shortening via |
We ended up reverting the |
We decided to not generate any JDK 9 argfile at this stage as the pathing JAR is good enough. |
Just want to ask, regarding this solution: is there a way to force the creation of the pathing jar? I find that I run into this problem when the |
That is a very good point, we addressed the issue strictly for |
Tried Gradle V 6.0 and still facing this issue for the kotlin compiler in windows.
|
This case seems to be related to the Kotlin compiler, I suggest you raise the issue with JetBrains to they use |
@arihunta, see #1989 (comment) for a work-around that does not require a pathing JAR. |
@lacasseio isn't that already tracked as part of #1989? |
For long classpaths execution may fail. This is especially prevalent on MS Windows. See gradle/gradle#10114 for further details of the problem. This commit copies the fix from Gradle: gradle/gradle#10544
For long classpaths execution may fail. This is especially prevalent on MS Windows. See gradle/gradle#10114 for further details of the problem. This commit copies the fix from Gradle: gradle/gradle#10544
For long classpaths execution may fail. This is especially prevalent on MS Windows. See gradle/gradle#10114 for further details of the problem. This commit copies the fix from Gradle: gradle/gradle#10544
For long classpaths execution may fail. This is especially prevalent on MS Windows. See gradle/gradle#10114 for further details of the problem. This commit copies the fix from Gradle: gradle/gradle#10544
My workaround is to create an argument file:
|
Expected Behavior
JavaExec
(task and inline method) can execute without any special handling on Windows as it does on Linux and macOS.Current Behavior
Windows has a limit in term of long path and command-line arguments size. Given a really long classpath, a
JavaExec
task would typically succeed on macOS and fail on Windows. This causes a lot of pain to users and requires to use house-made solution or rely on 3rd party plugins.Context
The text was updated successfully, but these errors were encountered: