-
-
Notifications
You must be signed in to change notification settings - Fork 52
Description
What happened?
Issue 1: Database Initialization Failure
When running cortex install without sudo, the application crashes with:
ERROR:cortex.installation_history:Failed to initialize database: unable to open database file
❌ Unexpected error: unable to open database file
Root Cause:
The _ensure_db_directory() method in InstallationHistory and SemanticCache classes only checks if the directory /var/lib/cortex/ can be created, but not if the user can actually write files inside it.
When /var/lib/cortex/ already exists (created by a previous sudo operation), mkdir(..., exist_ok=True) succeeds silently without raising PermissionError. The fallback to ~/.cortex/ never triggers, and SQLite fails when trying to create the database file.
Issue 2: Ollama Provider Choice Not Persisted
When a user selects Ollama as their provider (option 3), the choice is not saved. Every subsequent cortex command prompts the user to select a provider again.
Root Cause:
The prompt_for_key() method returns immediately for Ollama without offering to save the preference, unlike the behavior for API keys.
How to reproduce
Issue 1: Database Error
- Ensure /var/lib/cortex/ exists and is owned by root:
sudo mkdir -p /var/lib/cortex ls -la /var/lib/cortex/ # Should show: drwxr-xr-x root root - Run cortex as a non-root user:
cortex install nginx - Select Ollama (option 3) when prompted for provider then it will crash with "unable to open database file"
Issue 2: Ollama Provider Not Saved
- Remove any existing config:
rm -f ~/.cortex/.env - Run cortex and select Ollama:
cortex install nginx --dry-run # Select option 3 (Ollama) - Run cortex again:
cortex install docker --dry-run
This will remember Ollama preference, no prompt shown
Environment
- OS: Ubuntu 22.04+ / Debian 12+ (or any Linux distribution)
- Python: 3.10+
- User: Non-root user
- Condition: /var/lib/cortex/ directory exists (created by previous root/sudo operation)
- Ollama: Installed and running locally (for provider persistence issue)
Error output
