{"record":{"id":"4459e24334675e6a","repo":"JetBrains/intellij-community","slug":"0-is-disabled-in-fork-mode-br-change-fork-mode","errorCode":null,"errorMessage":"{0} is disabled in fork mode.<br/>Change fork mode to &lt;none&gt; to {1}.","messagePattern":"(.+?) is disabled in fork mode\\.<br/>Change fork mode to &lt;none&gt; to (.+?)\\.","errorType":"exception","errorClass":"CantRunException","httpStatus":null,"severity":"error","filePath":"java/execution/impl/src/com/intellij/execution/JavaTestFrameworkRunnableState.java","lineNumber":472,"sourceCode":"  }\n\n  public void appendForkInfo(Executor executor) throws ExecutionException {\n    final String forkMode = getForkMode();\n    if (Comparing.strEqual(forkMode, \"none\")) {\n      if (forkPerModule()) {\n        if (isExecutorDisabledInForkedMode()) {\n          final String actionName = executor.getActionName();\n          throw new CantRunException(JavaCompilerBundle.message(\"action.disabled.when.per.module.working.directory.configured\",\n                                                                actionName));\n        }\n      }\n      else {\n        return;\n      }\n    }\n    else if (isExecutorDisabledInForkedMode()) {\n      final String actionName = executor.getActionName();\n      throw new CantRunException(JavaCompilerBundle.message(\"action.disabled.in.fork.mode\", actionName,\n                                                            StringUtil.toLowerCase(actionName)));\n    }\n\n    final JavaParameters javaParameters = getJavaParameters();\n    final Sdk jdk = javaParameters.getJdk();\n    if (jdk == null) {\n      throw new ExecutionException(ExecutionBundle.message(\"run.configuration.error.no.jdk.specified\"));\n    }\n\n    try {\n      final File tempFile = FileUtil.createTempFile(\"command.line\", \"\", true);\n      try (PrintWriter writer = new PrintWriter(tempFile, StandardCharsets.UTF_8)) {\n        ShortenCommandLine shortenCommandLine = getConfiguration().getShortenCommandLine();\n        boolean useDynamicClasspathForForkMode = shortenCommandLine == null\n                                                 ? JdkUtil.useDynamicClasspath(getConfiguration().getProject())\n                                                 : shortenCommandLine != ShortenCommandLine.NONE;\n        if (shortenCommandLine == ShortenCommandLine.ARGS_FILE) {\n          //see com.intellij.rt.execution.testFrameworks.ForkedByModuleSplitter.startChildFork","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/execution/impl/src/com/intellij/execution/JavaTestFrameworkRunnableState.java#L454-L490","documentation":"JavaTestFrameworkRunnableState.appendForkInfo throws CantRunException with this message when the JUnit run configuration uses an explicit fork mode (other than 'none') and the selected executor is not the debugger (isExecutorDisabledInForkedMode: RunnerSettings not instanceof GenericDebuggerRunnerSettings). In fork mode each test class runs in its own JVM, so executors like Coverage or Profile cannot attach to the forked processes.","triggerScenarios":"JUnit run configuration with Fork mode set to 'class'/'method'/'repeat', then executed with Coverage, Profile, or any non-debug executor.","commonSituations":"Fork mode left enabled from memory-leak investigations; later attempting code coverage on the same configuration. Debug works (it knows how to attach to forks), Run sometimes silently degrades, but coverage/profilers hard-fail.","solutions":["Set Fork mode to 'none' in the JUnit run configuration, then re-run coverage/profiling","Or use Debug, which supports forked mode via GenericDebuggerRunnerSettings","Duplicate the configuration: keep a forked variant for leak hunting and a non-forked variant for coverage"],"exampleFix":"// before: JUnit config Fork mode = method, executed with Coverage\n// after: edit configuration -> Fork mode = none -> re-run Coverage","handlingStrategy":"validation","validationCode":"// guard: explicit fork mode + non-debug executor cannot work\nif (!\"none\".equals(cfg.getForkMode()) && !(settings instanceof GenericDebuggerRunnerSettings)) {\n  // coverage/profiling unsupported: fork none or use Debug\n}","typeGuard":null,"tryCatchPattern":"try {\n  state.appendForkInfo(executor);\n} catch (CantRunException e) {\n  offerToForkModeNone(e); // message tells user to set fork mode to none\n}","preventionTips":["Set fork mode to none when you plan to run coverage or profilers","Remember Debug works in fork mode, Coverage does not","Document team configurations: 'forked config = leak hunting only'"],"tags":["junit","run-configuration","fork-mode","coverage","profiling"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}