JetBrains/intellij-community · error · CantRunException

{0} is disabled in fork mode.<br/>Change fork mode to &lt;no

Error message

{0} is disabled in fork mode.<br/>Change fork mode to &lt;none&gt; to {1}.

What it means

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.

Source

Thrown at java/execution/impl/src/com/intellij/execution/JavaTestFrameworkRunnableState.java:472

  }

  public void appendForkInfo(Executor executor) throws ExecutionException {
    final String forkMode = getForkMode();
    if (Comparing.strEqual(forkMode, "none")) {
      if (forkPerModule()) {
        if (isExecutorDisabledInForkedMode()) {
          final String actionName = executor.getActionName();
          throw new CantRunException(JavaCompilerBundle.message("action.disabled.when.per.module.working.directory.configured",
                                                                actionName));
        }
      }
      else {
        return;
      }
    }
    else if (isExecutorDisabledInForkedMode()) {
      final String actionName = executor.getActionName();
      throw new CantRunException(JavaCompilerBundle.message("action.disabled.in.fork.mode", actionName,
                                                            StringUtil.toLowerCase(actionName)));
    }

    final JavaParameters javaParameters = getJavaParameters();
    final Sdk jdk = javaParameters.getJdk();
    if (jdk == null) {
      throw new ExecutionException(ExecutionBundle.message("run.configuration.error.no.jdk.specified"));
    }

    try {
      final File tempFile = FileUtil.createTempFile("command.line", "", true);
      try (PrintWriter writer = new PrintWriter(tempFile, StandardCharsets.UTF_8)) {
        ShortenCommandLine shortenCommandLine = getConfiguration().getShortenCommandLine();
        boolean useDynamicClasspathForForkMode = shortenCommandLine == null
                                                 ? JdkUtil.useDynamicClasspath(getConfiguration().getProject())
                                                 : shortenCommandLine != ShortenCommandLine.NONE;
        if (shortenCommandLine == ShortenCommandLine.ARGS_FILE) {
          //see com.intellij.rt.execution.testFrameworks.ForkedByModuleSplitter.startChildFork

View on GitHub (pinned to be881553f2)

Solutions

  1. Set Fork mode to 'none' in the JUnit run configuration, then re-run coverage/profiling
  2. Or use Debug, which supports forked mode via GenericDebuggerRunnerSettings
  3. Duplicate the configuration: keep a forked variant for leak hunting and a non-forked variant for coverage

Example fix

// before: JUnit config Fork mode = method, executed with Coverage
// after: edit configuration -> Fork mode = none -> re-run Coverage
Defensive patterns

Strategy: validation

Validate before calling

// guard: explicit fork mode + non-debug executor cannot work
if (!"none".equals(cfg.getForkMode()) && !(settings instanceof GenericDebuggerRunnerSettings)) {
  // coverage/profiling unsupported: fork none or use Debug
}

Try / catch

try {
  state.appendForkInfo(executor);
} catch (CantRunException e) {
  offerToForkModeNone(e); // message tells user to set fork mode to none
}

Prevention

When it happens

Trigger: JUnit run configuration with Fork mode set to 'class'/'method'/'repeat', then executed with Coverage, Profile, or any non-debug executor.

Common situations: 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.

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/4459e24334675e6a. Report an issue: GitHub.