Skip to content

Troubleshooting

Common issues and solutions for ZotMD.

Configuration Issues

Config not found

$ zotmd sync
Error: Not configured. Run 'zotmd config' first.

Solution: Run zotmd config to create the config file.

Invalid API key

$ zotmd config
Testing connection to Zotero...
Error: Failed to connect to Zotero API.

Solutions:

Invalid library ID

 Error: Library not found (403 Forbidden)

Solutions:

  • Verify library ID at zotero.org/settings/keys
  • Ensure library_type matches (user vs group)
  • For groups, ensure you're a member

Permission denied (output directory)

Error: Permission denied: /restricted/path

Solutions:

  • Choose a directory you have write access to
  • Create directory first: mkdir -p ~/notes/references
  • Check permissions: ls -ld ~/notes/references

Installation Issues

Command not found: zotmd

Problem:

$ zotmd --help
zotmd: command not found

Solutions:

  1. If installed with uv:

    # Ensure uv's bin directory is in PATH
    echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc
    
    # Verify installation
    uv tool list
    

  2. If installed with pipx:

    # Ensure pipx path
    pipx ensurepath
    source ~/.zshrc
    

  3. Reinstall:

    uv tool install --force zotmd
    

Python version too old

Problem:

ERROR: Package requires Python >=3.13

Solution:

# Install Python 3.13+ with uv
uv python install 3.13

# Or use system package manager
# macOS:
brew install python@3.13

# Linux:
sudo apt install python3.13

Connection Issues

Cannot connect to Zotero

Problem:

$ zotmd status
✗ Error: Connection refused

Solutions:

  1. Enable API access:
  2. Zotero -> Settings -> Advanced -> Miscellaneous
  3. Check "Allow other applications to access Zotero"

  4. Verify credentials:

    zotmd config  # Re-enter credentials
    

  5. Test API manually:

    curl "https://api.zotero.org/users/YOUR_ID/items?limit=1&key=YOUR_KEY"
    

403 Forbidden Error

Problem:

 Error: 403 Forbidden

Causes & Solutions:

  1. Wrong library_type:
  2. Personal library: Use library_type = "user"
  3. Group library: Use library_type = "group"

  4. Invalid API key:

  5. Regenerate at zotero.org/settings/keys/new
  6. Ensure "Allow library access" is checked

  7. Wrong library ID:

  8. Verify at zotero.org/settings/keys
  9. For groups: Use group ID, not user ID

Rate Limiting

Problem:

 Error: 429 Too Many Requests

Solution: Wait a few minutes before retrying. Zotero API has rate limits: - Personal tier: 120 requests/minute - Group tier: Shared across all members

Sync Issues

Items missing citation keys

Problem:

Skipped 45 items without citation keys

Solution:

  1. Install Better BibTeX:
  2. Download: retorque.re/zotero-better-bibtex
  3. Zotero -> Tools -> Add-ons -> Install from File

  4. Generate citation keys:

  5. Select all items in Zotero
  6. Right-click -> Better BibTeX -> Refresh BibTeX key

  7. Re-sync:

    zotmd sync
    

Annotations not appearing

Problem: PDF highlights not showing in Markdown files.

Solutions:

  1. Ensure PDF is in Zotero:
  2. Attachment must be stored in Zotero (not linked file)
  3. Check: Item has PDF icon, not link icon

  4. Annotations must be created in Zotero:

  5. Use Zotero's built-in PDF reader
  6. External annotations (Adobe, Preview) won't sync

  7. Force re-sync:

    zotmd sync --full
    

Deleted items reappearing

Problem: Deleted Markdown files come back after sync.

Cause: Items still exist in Zotero library.

Solution:

  1. Delete from Zotero first:
  2. Delete item in Zotero
  3. Empty Zotero trash
  4. Run zotmd sync

  5. Or remove from filesystem only:

  6. Set deletion_behavior = "delete" in config
  7. Files won't be recreated if deleted locally

User notes being overwritten

Problem: Custom notes in Markdown files are lost after sync.

Solution:

Place notes in the designated section:

## Notes
<!-- Add your notes below this line -->
<!-- They will be preserved across syncs -->

Your custom notes here...

Content above this section will be regenerated on each sync.

Database Issues

Corrupted database

Problem:

Error: database disk image is malformed

Solution:

  1. Backup current database:

    # macOS
    cp ~/.local/share/zotmd/sync.sqlite ~/sync.sqlite.backup
    
    # Linux
    cp ~/.local/share/zotmd/sync.sqlite ~/sync.sqlite.backup
    

  2. Delete and re-sync:

    rm ~/.local/share/zotmd/sync.sqlite
    zotmd sync --full
    

Database locked

Problem:

Error: database is locked

Solution:

  1. Check for other zotmd processes:

    ps aux | grep zotmd
    kill <PID>  # If found
    

  2. Remove lock file:

    rm ~/.local/share/zotmd/sync.sqlite-journal
    

File System Issues

Permission denied

Problem:

Error: Permission denied: /path/to/output

Solutions:

  1. Create directory:

    mkdir -p ~/notes/references
    

  2. Fix permissions:

    chmod 755 ~/notes/references
    

  3. Choose different path:

    zotmd config  # Enter accessible directory
    

Filename too long

Problem:

OSError: File name too long

Cause: Citation keys longer than filesystem limit (255 chars).

Solution:

  1. Shorten citation key in Better BibTeX:
  2. Right-click item -> Better BibTeX -> Pin/Set citation key
  3. Enter shorter key

  4. Change citation key pattern:

  5. Zotero Settings -> Better BibTeX -> Citation Keys
  6. Use shorter pattern (e.g., [auth:lower][year])

Special characters in filenames

Problem: Files with invalid characters (/, :, *, etc.)

Solution:

ZotMD automatically sanitizes filenames, but if issues persist:

  1. Check citation key:
  2. Avoid: < > : " / \ | ? *
  3. Better BibTeX usually handles this

  4. Manually fix:

  5. Edit citation key in Zotero
  6. Remove problematic characters

Template Issues

Template not found

Problem:

Error: Template file not found: /path/to/template.md.j2

Solutions:

  1. Verify path:

    ls -l /path/to/template.md.j2
    

  2. Use absolute path in config:

    template_path = "/Users/me/templates/custom.md.j2"
    

  3. Reset to default:

    template_path = ""  # Empty uses built-in
    

Template syntax error

Problem:

jinja2.exceptions.TemplateSyntaxError: unexpected '}'

Solution:

  1. Validate Jinja2 syntax:
  2. Check matching {% ... %}, {{ ... }}
  3. Ensure proper indentation

  4. Test with default template:

    template_path = ""
    
    zotmd sync --full
    

  5. Debug template:

    zotmd sync --verbose
    

Performance Issues

Sync is very slow

Problem: Full sync takes hours for large library.

Solutions:

  1. Use incremental sync:

    zotmd sync  # Default, not --full
    

  2. Check network:

  3. Zotero API may be slow
  4. Try at different time

  5. Reduce annotation processing:

  6. Large PDFs with many annotations take time
  7. This is expected behavior

High memory usage

Problem: Process using excessive RAM.

Cause: Large library with many annotations.

Mitigation:

  1. Process in batches (not yet supported - feature request)
  2. Close other applications
  3. Increase system swap space

Getting Help

If you encounter an issue not listed here:

  1. Check existing issues: github.com/adbX/zotmd/issues

  2. Run with verbose logging:

    zotmd sync --verbose 2>&1 | tee debug.log
    

  3. Create new issue with:

  4. Error message
  5. Steps to reproduce
  6. debug.log output
  7. OS and Python version
  8. zotmd status output

Useful Diagnostic Commands

# Check config
zotmd status

# Test connection only
zotmd config  # Will test during setup

# View config file
cat ~/.config/zotmd/config.toml  # macOS/Linux

# Check database
sqlite3 ~/.local/share/zotmd/sync.sqlite "SELECT COUNT(*) FROM sync_items;"

# List installed version
uv tool list | grep zotmd