vscode-java-test icon indicating copy to clipboard operation
vscode-java-test copied to clipboard

failed to launch debuggee VM. Filename or Extension is too long. args too long?

Open dsimonow opened this issue 1 year ago • 5 comments

Hi, I am trying to get our maven multi project to run in VSCode. One Package fails and throws this error:

Juli 30, 2024 6:01:44 PM org.apache.aries.spifly.BaseActivator log
INFORMATION: Registered provider ch.qos.logback.classic.servlet.LogbackServletContainerInitializer of service jakarta.servlet.ServletContainerInitializer in bundle ch.qos.logback.classic
Juli 30, 2024 6:01:44 PM org.apache.aries.spifly.BaseActivator log
INFORMATION: Registered provider ch.qos.logback.classic.spi.LogbackServiceProvider of service org.slf4j.spi.SLF4JServiceProvider in bundle ch.qos.logback.classic
Juli 30, 2024 6:03:01 PM com.microsoft.java.debug.plugin.internal.JavaDebuggerServerPlugin start
INFORMATION: Starting com.microsoft.java.debug.plugin
Juli 30, 2024 6:03:01 PM com.microsoft.java.debug.plugin.internal.LogUtils configLogLevel
INFORMATION: Set log level to : FINE
Juli 30, 2024 6:03:40 PM com.microsoft.java.debug.plugin.internal.Compile compile
INFORMATION: Time cost for ECJ: 39098ms
Juli 30, 2024 6:03:40 PM com.microsoft.java.debug.core.UsageDataSession recordInfo
INFORMATION: launch debug info
Juli 30, 2024 6:03:40 PM com.microsoft.java.debug.core.adapter.handler.LaunchRequestHandler launch
INFORMATION: Trying to launch Java Program with options:
main-class: com.microsoft.java.test.runner.Launcher
args: 53015 testng (Alot of method names that I can't share. Editor says 175735 characters)
module-path: 
class-path: 
vmArgs:  "@C:\Users\simonow\AppData\Local\Temp\cp_7m7fi6jj88wslefmewdwqipfm.argfile"
[Error - 6:03:40 PM] 30.07.2024, 18:03:40 [error response][launch]: Failed to launch debuggee VM. Reason: java.io.IOException: Cannot run program "C:\Program Files\Eclipse Adoptium\jdk-11.0.24.8-hotspot\bin\java.exe" (in directory "C:\Dev\Projekte\Repos\project-name\project-name-web\project-name-web-ui"): CreateProcess error=206, Der Dateiname oder die Erweiterung ist zu lang
Failed to launch debuggee VM. Reason: java.io.IOException: Cannot run program "C:\Program Files\Eclipse Adoptium\jdk-11.0.24.8-hotspot\bin\java.exe" (in directory "C:\Dev\Projekte\Repos\project-name\project-name-web\project-name-web-ui"): CreateProcess error=206, Der Dateiname oder die Erweiterung ist zu lang
com.microsoft.java.debug.core.DebugException: Failed to launch debuggee VM. Reason: java.io.IOException: Cannot run program "C:\Program Files\Eclipse Adoptium\jdk-11.0.24.8-hotspot\bin\java.exe" (in directory "C:\Dev\Projekte\Repos\project-name\project-name-web\project-name-web-ui"): CreateProcess error=206, Der Dateiname oder die Erweiterung ist zu lang

the generated argfile has about 15k characters and starts with -ea -Dfile.encoding=UTF-8 -cp "..."

Sorry for the german in there. "Der Dateiname oder die Erweiterung ist zu lang" is basically "Filename or Extension is too long"

I tried all of the launch.json Settings for shortenCommandLine, this itteration tries it with the argfile.

I also attempted to relocate the jdk and had it at one point at C:\jdk and it didn't matter either. I know these Tests work, since they do work in Eclipse and Intellij I am just trying to make it work in vscode.

I am assuming the extremely long args is causing the issue, since that specific project has probably most of our tests and the others seem to work. Now how would I resolve that since it does work in other IDEs? Also I don't think our project is that unique in the amount of tests we have, we are still a rather young project in terms of javaee development.

dsimonow avatar Jul 30 '24 16:07 dsimonow

It's because here https://github.com/microsoft/vscode-java-test/blob/ad4b37c7529e4a6825bd1f8ceb545ee783e7c837/src/utils/launchUtils.ts#L27

When the extension tries to construct the launch configuration for debug, the shortedCommandLine is not supported. Maybe to solve this problem, we should expose this configuration to vscode settings from debugger extension.

jdneo avatar Jul 31 '24 02:07 jdneo

Or another quick fix is always enable shortenCommandLine

jdneo avatar Jul 31 '24 08:07 jdneo

Hi @dsimonow, could you please try this to see if it fixes your problem: extension.vsix.zip

jdneo avatar Jul 31 '24 10:07 jdneo

thank you for the fast reply. Sadly this doesn't change it. Like in the stacktrace it seems to use an argfile which I think is a command shortening strategy.

I tried more testing and I think it has something to do with the strategy of the Test Explorer itself. It seems to go per package and attempts to summarize everything inside. Instead of working through them, which causes apparently these too long args.

It causes the error when I used the top most button to basically test everything and it reaches the package with the large amount of tests but also fails instantly if I try to test the package with too many tests inside. While going through them each inside the package doesn't cause the error.

Are there ways to adjust the strategy of the test runner? accept more time by it going through the packages instead of summarizing them?

dsimonow avatar Jul 31 '24 13:07 dsimonow

Ah I see. Sorry I misunderstood the issue at first. So it's the argument length too long.

Then I need to check if I can fold the argument. For example, if all the classes under the same package are being tested, then fold the class fully qualified names to the belonging package name

jdneo avatar Aug 01 '24 02:08 jdneo

@jdneo we have the same problem if you try to run all the testcases in a maven module.

Dec 10, 2024 11:41:21 AM com.microsoft.java.debug.core.adapter.ProtocolServer lambda$dispatchRequest$1
SEVERE: [error response][launch]: Failed to launch debuggee VM. Reason: java.io.IOException: Cannot run program "C:\Program Files\Zulu\zulu-21\bin\java.exe" (in directory "C:\Users\eraonel\git\mje\msran-jcat-extension-actions"): CreateProcess error=206, The filename or extension is too long
com.microsoft.java.debug.core.DebugException: Failed to launch debuggee VM. Reason: java.io.IOException: Cannot run program "C:\Program Files\Zulu\zulu-21\bin\java.exe" (in directory "C:\Users\eraonel\git\mje\msran-jcat-extension-actions"): CreateProcess error=206, The filename or extension is too long
	at com.microsoft.java.debug.core.adapter.handler.LaunchRequestHandler.launch(LaunchRequestHandler.java:333)
	at com.microsoft.java.debug.core.adapter.handler.LaunchRequestHandler.handleLaunchCommand(LaunchRequestHandler.java:193)
	at com.microsoft.java.debug.core.adapter.handler.LaunchRequestHandler.handle(LaunchRequestHandler.java:95)
	at com.microsoft.java.debug.core.adapter.DebugAdapter.lambda$dispatchRequest$0(DebugAdapter.java:94)
	at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1187)
	at java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2341)
	at com.microsoft.java.debug.core.adapter.DebugAdapter.dispatchRequest(DebugAdapter.java:93)
	at com.microsoft.java.debug.core.adapter.ProtocolServer.dispatchRequest(ProtocolServer.java:132)
	at com.microsoft.java.debug.core.protocol.AbstractProtocolServer.lambda$new$0(AbstractProtocolServer.java:81)
	at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:63)
	at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:201)
	at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255)
	at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
	at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)

Have you had a chance to look into this?

mpet avatar Dec 10 '24 11:12 mpet

Hi @dsimonow, I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.

The error CreateProcess error=206 on Windows means the total command-line (including all VM args and test filters) exceeds the OS limit (~32 K chars), even when using @argfile. Here are some workarounds:

• Switch from listing individual methods to a TestNG suite XML: – Create a testng.xml that groups your tests into suites/packages instead of passing 175 K chars of --methods. – Add in launch.json under the TestNG launcher:
json "testNgOptions": { "suiteXmlPaths": ["${workspaceFolder}/path/to/testng.xml"] } – This keeps the CLI very short and delegates test selection to TestNG.

• Use Maven’s Surefire or Failsafe plugin (via the VS Code Maven extension) to run/debug tests: – In VS Code’s Maven explorer, right-click your project → Debug… → targets test or failsafe:test. – This bypasses the Java debugger’s long-arg handling entirely.

• Condense your classpath into a class-path.jar (manifest-based) to shorten -cp entries: – See “classpath jar” support in the Java debugging docs:
https://code.visualstudio.com/docs/java/java-debug#_shorten-command-line

None of the provided GitHub issues directly address Windows CreateProcess 206 for oversized test lists.

The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!

github-actions[bot] avatar Nov 12 '25 22:11 github-actions[bot]