{"record":{"id":"1de2fbf16b2847f1","repo":"JetBrains/intellij-community","slug":"associated-scratch-file-not-found","errorCode":null,"errorMessage":"Associated scratch file not found","messagePattern":"Associated scratch file not found","errorType":"validation","errorClass":"RuntimeConfigurationError","httpStatus":null,"severity":"error","filePath":"java/execution/impl/src/com/intellij/execution/scratch/JavaScratchConfiguration.java","lineNumber":72,"sourceCode":"  }\n\n  @Override\n  public boolean isBuildProjectOnEmptyModuleList() {\n    return false;\n  }\n\n  @Override\n  public void checkConfiguration() throws RuntimeConfigurationException {\n    JavaParametersUtil.checkAlternativeJRE(this);\n    final String className = getMainClassName();\n    if (className == null || className.isEmpty()) {\n      throw new RuntimeConfigurationError(ExecutionBundle.message(\"no.main.class.specified.error.text\"));\n    }\n    if (getScratchFileUrl() == null) {\n      throw new RuntimeConfigurationError(JavaCompilerBundle.message(\"error.no.scratch.file.associated.with.configuration\"));\n    }\n    if (getScratchVirtualFile() == null) {\n      throw new RuntimeConfigurationError(JavaCompilerBundle.message(\"error.associated.scratch.file.not.found\"));\n    }\n    ProgramParametersUtil.checkWorkingDirectoryExist(this, getProject(), getConfigurationModule().getModule());\n    JavaRunConfigurationExtensionManager.checkConfigurationIsValid(this);\n  }\n\n  @Override\n  public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {\n    final JavaCommandLineState state = new JavaApplicationCommandLineState<>(this, env) {\n      @Override\n      protected JavaParameters createJavaParameters() throws ExecutionException {\n        final JavaParameters params = super.createJavaParameters();\n        // After params are fully configured, additionally ensure JAVA_ENABLE_PREVIEW_PROPERTY is set,\n        // because the scratch is compiled with this feature if it is supported by the JDK\n        final Sdk jdk = params.getJdk();\n        if (jdk != null) {\n          final JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk);\n          if (version != null && version.getMaxLanguageLevel().isPreview()) {\n            final ParametersList vmOptions = params.getVMParametersList();","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/execution/impl/src/com/intellij/execution/scratch/JavaScratchConfiguration.java#L54-L90","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// verify the URL resolves to a live VFS file before running\nVirtualFile scratch = VfsUtil.findFileByURL(VfsUtilCore.convertFromUrl(url));\nif (scratch == null || !scratch.isValid()) {\n  return notify(\"Scratch file no longer exists — recreate it\");\n}","typeGuard":"boolean scratchResolvable(JavaScratchConfiguration c) {\n  return c.getScratchFileUrl() != null && c.getScratchVirtualFile() != null;\n}","tryCatchPattern":"try {\n  configuration.checkConfiguration();\n} catch (RuntimeConfigurationError e) {\n  // associated scratch vanished: offer to locate/recreate it\n  offerScratchRestore();\n}","preventionTips":["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"],"tags":["scratch-file","vfs","run-configuration","missing-file"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}