JetBrains/intellij-community · error · RuntimeConfigurationError
Associated scratch file not found
Error message
Associated scratch file not found
What it means
JavaScratchConfiguration.checkConfiguration throws RuntimeConfigurationError('Associated scratch file not found') when a scratch file URL is present but getScratchVirtualFile() resolves it to null — the URL points to a file that can no longer be found in the VFS (file deleted, moved, outside the workspace and not refreshed).
Source
Thrown at java/execution/impl/src/com/intellij/execution/scratch/JavaScratchConfiguration.java:72
}
@Override
public boolean isBuildProjectOnEmptyModuleList() {
return false;
}
@Override
public void checkConfiguration() throws RuntimeConfigurationException {
JavaParametersUtil.checkAlternativeJRE(this);
final String className = getMainClassName();
if (className == null || className.isEmpty()) {
throw new RuntimeConfigurationError(ExecutionBundle.message("no.main.class.specified.error.text"));
}
if (getScratchFileUrl() == null) {
throw new RuntimeConfigurationError(JavaCompilerBundle.message("error.no.scratch.file.associated.with.configuration"));
}
if (getScratchVirtualFile() == null) {
throw new RuntimeConfigurationError(JavaCompilerBundle.message("error.associated.scratch.file.not.found"));
}
ProgramParametersUtil.checkWorkingDirectoryExist(this, getProject(), getConfigurationModule().getModule());
JavaRunConfigurationExtensionManager.checkConfigurationIsValid(this);
}
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
final JavaCommandLineState state = new JavaApplicationCommandLineState<>(this, env) {
@Override
protected JavaParameters createJavaParameters() throws ExecutionException {
final JavaParameters params = super.createJavaParameters();
// After params are fully configured, additionally ensure JAVA_ENABLE_PREVIEW_PROPERTY is set,
// because the scratch is compiled with this feature if it is supported by the JDK
final Sdk jdk = params.getJdk();
if (jdk != null) {
final JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk);
if (version != null && version.getMaxLanguageLevel().isPreview()) {
final ParametersList vmOptions = params.getVMParametersList();View on GitHub (pinned to be881553f2)
Solutions
- Restore or recreate the scratch file with the same name under the Scratches directory, then re-run
- Otherwise delete the broken configuration and create a fresh one by running the scratch file
- If the file exists but is not found, trigger a VFS refresh (Synchronize, Ctrl+Alt+Y) and retry
Defensive patterns
Strategy: validation
Validate before calling
// verify the URL resolves to a live VFS file before running
VirtualFile scratch = VfsUtil.findFileByURL(VfsUtilCore.convertFromUrl(url));
if (scratch == null || !scratch.isValid()) {
return notify("Scratch file no longer exists — recreate it");
} Type guard
boolean scratchResolvable(JavaScratchConfiguration c) {
return c.getScratchFileUrl() != null && c.getScratchVirtualFile() != null;
} Try / catch
try {
configuration.checkConfiguration();
} catch (RuntimeConfigurationError e) {
// associated scratch vanished: offer to locate/recreate it
offerScratchRestore();
} Prevention
- Restore scratches from version control if you sync run configurations between machines
- After moving/renaming scratches, re-create the run configuration
- Force a VFS refresh (Ctrl+Alt+Y) if the file exists but is reported missing
When it happens
Trigger: The stored scratch file URL does not resolve to a VirtualFile: scratch deleted or renamed after the configuration was created, project opened on another machine, or the VFS has not yet refreshed the scratches directory.
Common situations: Syncing run configurations via version control or Settings Sync to machines that lack the scratch; deleting a scratch file from the Scratches tool window while its run configuration remains.
Related errors
- No main class specified
- No scratch file associated with configuration
- '{0}' is disabled when per-module working directory is confi
- {0} is disabled in fork mode.<br/>Change fork mode to <no
- No JDK specified
AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14).
Data as JSON: /api/errors/1de2fbf16b2847f1.
Report an issue: GitHub.