Windows 10系统下VSCode中Agda-mode触发快捷键时报错Unable to open 'Agda': AbstractContextKeyService has been disposed的求助
I’ve dealt with this exact frustrating error when using Agda-mode in VSCode on Windows 10, so let’s go through actionable fixes that should resolve it—since restarting your PC isn’t working anymore.
Reload the VSCode Window (don’t just restart the app)
The VSCode extension host can sometimes glitch out, leaving context services likeAbstractContextKeyServicein a disposed state. A full window reload resets these services properly:- Press
Ctrl+Shift+Pto open the command palette. - Search for and run
Developer: Reload Window. - Once VSCode refreshes, test your Agda-mode shortcuts (like
Ctrl+C Ctrl+L) again.
- Press
Clean Reinstall the Agda VSCode Extension
Corrupted extension files often cause these odd service-related errors. Here’s how to do a clean reinstall:- Open VSCode’s Extensions tab with
Ctrl+Shift+X. - Locate the Agda extension, click the gear icon, and select
Uninstall. - Close VSCode entirely—make sure it’s not running in your system tray.
- Reopen VSCode, search for Agda in the Extensions tab, and reinstall it.
- After installation, reload the VSCode window once more using the command from the first fix.
- Open VSCode’s Extensions tab with
Verify Your Agda System Installation
Sometimes the issue isn’t with VSCode, but with Agda itself not being set up correctly:- Open Command Prompt by pressing
Win+R, typingcmd, and hitting Enter. - Run
agda --versionto check if Agda is accessible via your system PATH. If this command fails, you’ll need to repair your Agda installation (reinstall it via Chocolatey, Cabal, or your preferred package manager, ensuring it’s added to your system PATH). - If the version check works, try compiling a simple Agda file directly from the command line with
agda your-test-file.agdato confirm Agda runs properly outside VSCode.
- Open Command Prompt by pressing
Reset VSCode Settings (Last Resort)
If all else fails, a corrupted VSCode configuration might be conflicting with Agda-mode:- Press
Ctrl+Shift+Pand runPreferences: Open Settings (JSON). - Copy and save the contents of this file somewhere safe (so you can restore custom settings later).
- Delete all content in the settings JSON file, save it, then reload the VSCode window.
- Manually reconfigure any Agda-mode or VSCode settings you had previously, then test the shortcuts again.
- Press
内容的提问来源于stack exchange,提问作者kuco 23

