[Conda] Error: CondaIndexError — invalid index file or corrupt repodata.json — How to Fix It
Summary
The CondaIndexError: invalid index file or corrupt repodata.json occurs when Conda fails to read the metadata index (repodata.json) from a repository channel. This file lists all available packages and dependencies, so when it’s incomplete, corrupted, or outdated, Conda can’t resolve package requests. The fix is to clean the cache and force Conda to re-download a fresh index.
Context
Every Conda channel maintains a repodata.json file — a JSON index that describes all packages available for that repository. When Conda installs or updates a package, it fetches and caches this metadata. If the file becomes damaged or truncated (due to interrupted downloads, proxy issues, or local corruption), Conda can’t parse it, triggering the error. Cleaning and rebuilding the cache usually resolves it.
Probable Cause
- Corrupted or partially downloaded
repodata.jsonfile in Conda’s cache. - Interrupted or incomplete network connection during metadata retrieval.
- Outdated index metadata mismatched with channel contents.
- Using a broken, offline, or local mirror missing index data.
- Proxy or SSL errors while downloading repository information.
Quick Fix
Use the following sequence to restore Conda’s metadata integrity:
- Clear the index cache:
conda clean --index-cache --yes
- Rebuild metadata and update Conda:
conda clean --all
conda update conda
- Retry the previous installation or update:
conda install <package>
- If the issue persists, identify the failing channel (shown in the error output) and disable it temporarily:
conda config --remove channels <channel-name>
- Switch to a stable mirror such as
conda-forge:
conda config --add channels conda-forge
- If using a local or offline repository, reindex it manually:
conda index /path/to/local/channel
- Verify online mode and connectivity:
conda info
# Ensure it shows: offline mode: False
Full Example
Example error message:
CondaIndexError: invalid index file: repodata.json
ValueError: Expecting value: line 1 column 1 (char 0)
Fix steps:
conda clean --index-cache --yes
conda clean --all
conda update conda
conda install numpy
If you identify a broken channel like https://repo.anaconda.com/pkgs/main/, remove it and add a fresh mirror:
conda config --remove channels defaults
conda config --add channels conda-forge
Pitfalls & Debug
- Symptom: JSONDecodeError — Fix: Clear index cache and retry download.
- Symptom: Repeated failure on the same channel — Fix: Switch to another mirror (e.g., conda-forge).
- Symptom: Works offline but not online — Fix: Check proxy and SSL configuration.
- Symptom: Local mirror errors — Fix: Rebuild index manually with
conda index.
Validation & Next Steps
After applying the fix:
conda clean --index-cache
conda install requests
Check that repodata.json is regenerated under ~/.conda/pkgs/cache/ without parsing errors. The command should execute normally.
Sources
Anaconda Documentation — Managing channels and metadata
conda-forge — stable channel mirrors and indexing tools
Stack Overflow — community fixes for Conda index corruption
YAML & JSON parsing references — common data validation issues in repodata