JetBrains/intellij-community · error · CantRunException

'{0}' is disabled when per-module working directory is confi

Error message

'{0}' is disabled when per-module working directory is configured.<br/>Specify a single working directory, or change the test scope to a single module.

What it means

JavaTestFrameworkRunnableState.appendForkInfo throws CantRunException with this message when fork mode is 'none' but 'fork per module' working-directory mode is enabled and the chosen executor is not the debugger (anything but GenericDebuggerRunnerSettings). Per-module forking spawns one JVM per module with its own working directory, which cannot be combined with e.g. coverage or profiler executors.

Source

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

      catch (IOException e) {
        LOG.error(e);
      }
    }
    return myForkSocket;
  }

  private boolean isExecutorDisabledInForkedMode() {
    final RunnerSettings settings = getRunnerSettings();
    return settings != null && !(settings instanceof GenericDebuggerRunnerSettings);
  }

  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"));
    }

View on GitHub (pinned to be881553f2)

Solutions

  1. Run the configuration with the plain Run or Debug executor instead of Coverage/Profile
  2. Or change the JUnit run configuration to a single explicit working directory (unset the per-module working directory option)
  3. Or change the test scope to a single module, as the message suggests
  4. Create a separate run configuration without per-module working dir specifically for coverage/profiling

Example fix

// before: JUnit run configuration with working directory '$MODULE_WORKING_DIR$' + Run with Coverage
// after: set Working directory to a concrete path ($ProjectFileDir$) or run with plain Run/Debug
Defensive patterns

Strategy: validation

Validate before calling

// before running with a non-debug executor, check the configuration
JUnitConfiguration cfg = ...;
boolean perModuleDir = cfg.isForkPerModule(); // per-module working dir mode
boolean debuggerRunner = runnerSettings instanceof GenericDebuggerRunnerSettings;
if (perModuleDir && !debuggerRunner) {
  Messages.showWarning("Per-module working directory requires Run/Debug");
  return;
}

Try / catch

try {
  state.appendForkInfo(executor);
} catch (CantRunException e) {
  notifyUserAndOfferToSwitchExecutor(e); // suggest plain Run/Debug
}

Prevention

When it happens

Trigger: Run/coverage/profile a JUnit run configuration whose 'fork mode' is set to 'none' while the alternative 'fork per module' working directory option (Working directory: $MODULE_DIR$ style per-module mode) is selected in the JUnit run configuration.

Common situations: A team-shared JUnit configuration uses per-module working directories for forked tests; someone then runs it with Coverage or Profile instead of Run/Debug and gets this hard stop.

Related errors


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