{"record":{"id":"8b20625d6993d20b","repo":"JetBrains/intellij-community","slug":"0-is-disabled-when-per-module-working-director","errorCode":null,"errorMessage":"'{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.","messagePattern":"'(.+?)' is disabled when per-module working directory is configured\\.<br/>Specify a single working directory, or change the test scope to a single module\\.","errorType":"exception","errorClass":"CantRunException","httpStatus":null,"severity":"error","filePath":"java/execution/impl/src/com/intellij/execution/JavaTestFrameworkRunnableState.java","lineNumber":462,"sourceCode":"      catch (IOException e) {\n        LOG.error(e);\n      }\n    }\n    return myForkSocket;\n  }\n\n  private boolean isExecutorDisabledInForkedMode() {\n    final RunnerSettings settings = getRunnerSettings();\n    return settings != null && !(settings instanceof GenericDebuggerRunnerSettings);\n  }\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    }","sourceCodeStart":444,"sourceCodeEnd":480,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/execution/impl/src/com/intellij/execution/JavaTestFrameworkRunnableState.java#L444-L480","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run the configuration with the plain Run or Debug executor instead of Coverage/Profile","Or change the JUnit run configuration to a single explicit working directory (unset the per-module working directory option)","Or change the test scope to a single module, as the message suggests","Create a separate run configuration without per-module working dir specifically for coverage/profiling"],"exampleFix":"// before: JUnit run configuration with working directory '$MODULE_WORKING_DIR$' + Run with Coverage\n// after: set Working directory to a concrete path ($ProjectFileDir$) or run with plain Run/Debug","handlingStrategy":"validation","validationCode":"// before running with a non-debug executor, check the configuration\nJUnitConfiguration cfg = ...;\nboolean perModuleDir = cfg.isForkPerModule(); // per-module working dir mode\nboolean debuggerRunner = runnerSettings instanceof GenericDebuggerRunnerSettings;\nif (perModuleDir && !debuggerRunner) {\n  Messages.showWarning(\"Per-module working directory requires Run/Debug\");\n  return;\n}","typeGuard":null,"tryCatchPattern":"try {\n  state.appendForkInfo(executor);\n} catch (CantRunException e) {\n  notifyUserAndOfferToSwitchExecutor(e); // suggest plain Run/Debug\n}","preventionTips":["Keep a dedicated non-forked run configuration for coverage and profiling","Reserve per-module working directories for plain test runs","Read the configuration's fork/working-directory settings before choosing the executor"],"tags":["junit","run-configuration","fork-mode","coverage","working-directory"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}