Fix VS Code Code Runner Errors: "Extension Host Terminated" & "code-runner.run not found"

Fix VS Code Code Runner Errors: "Extension Host Terminated" & "code-runner.run not found"
3 mins read
3 Likes
9 Views

If you are trying to run Java or other code in VS Code using the Code Runner extension and encounter errors like:

  • “Extension host terminated unexpectedly”
  • “code-runner.run not found”

even after restarting your computer, reinstalling VS Code, or reinstalling the extension, don’t worry—this is a common issue that can usually be resolved with a few steps.

Problem Overview

Users often see this issue when:

  1. They try running a Java or other language file via Code Runner.

  2. VS Code throws the error:

    Plain Text
    Extension host terminated unexpectedly
  3. Attempting to run the code again shows:

    Plain Text
    code-runner.run not found
  4. Reinstalling the extension or VS Code doesn’t fix the problem.

This happens because some residual files in the extension directory can get corrupted, causing VS Code to fail in loading the extension properly.


Step-by-Step Solution

Step 1: Close VS Code

Ensure VS Code is fully closed, including all background processes.

Step 2: Delete the Extension Folder

Locate the Code Runner extension folder:

Plain Text
C:\Users\.vscode\extensions\formulahendry.code-runner-0.12.2

Important: Replace `` with your Windows username. Delete this folder completely. This removes any corrupted files that may be causing the problem.

Step 3: Reinstall the Extension

  1. Open VS Code.
  2. Go to the Extensions tab (Ctrl+Shift+X).
  3. Search for Code Runner.
  4. Click Install.

This installs a fresh copy of the extension without any corrupted files.

Step 4: Restart VS Code

After reinstalling, restart VS Code completely. Avoid just closing the editor window; make sure the background processes are also closed.

Step 5: Test Your Code

Open your test.java (or any other language file) and run it using Code Runner. For example:

Java
1public class Test {
2    public static void main(String[] args) {
3        System.out.println("Hello World");
4    }
5}

Click the Run Code button or use the shortcut (usually Ctrl+Alt+N). You should see the output in the Output tab.


Why This Works

  • Deleting the extension folder removes corrupted or partially installed files.
  • Reinstalling the extension ensures all dependencies and settings are restored.
  • This fixes the “Extension host terminated unexpectedly” and “code-runner.run not found” errors.

Additional Tips

  1. Keep VS Code updated: Always use the latest version of VS Code.
  2. Check other extensions: Sometimes conflicts occur with other installed extensions. Try disabling unnecessary ones.
  3. Reset VS Code settings: If problems persist, consider resetting VS Code settings from:

    Plain Text
    File -> Preferences -> Settings -> Reset Settings

Conclusion

If Code Runner is not working and shows errors like “Extension host terminated unexpectedly” or “code-runner.run not found”, the most effective solution is:

  1. Delete the extension folder from .vscode/extensions.
  2. Reinstall the extension.
  3. Restart VS Code.

After these steps, Code Runner should function normally, and your code should run without errors.

Share:

Comments

0
Join the conversation

Sign in to share your thoughts and connect with other readers

No comments yet

Be the first to share your thoughts!