sentry cli fix
Diagnose and repair issues with the Sentry CLI’s local SQLite database, including schema inconsistencies, file permissions, and ownership problems.Usage
What It Does
Thesentry cli fix command performs a comprehensive health check of the CLI’s local database and configuration directory, then repairs any issues it finds. The command:
- Checks ownership - Detects files owned by root (e.g., after
sudo brew install) - Checks permissions - Verifies config directory (0700) and database files (0600) have correct permissions
- Checks schema - Validates database schema version and structure
- Adds missing tables and columns (never deletes data)
- Fixes file permissions to secure defaults
- Transfers ownership back to the current user when run with sudo
Flags
Diagnostic Mode
Show what would be fixed without making any changes. Useful for previewing issues before repair.
Examples
Diagnose and Fix Issues
Preview Issues Without Fixing
Fix Root-Owned Files
sudo brew install), use sudo to transfer ownership back to your user:
When to Use It
Runsentry cli fix when you encounter:
Schema Upgrades
After upgrading to a new CLI version, the database schema may need migration:- Missing tables or columns
- Outdated schema version
Permission Errors
When the CLI reports permission denied errors:- EACCES when trying to access the database
- Permission issues after changing user or system configuration
Root-Owned Files
After operations that run as root:sudo brew install sentry-cli- Manual file operations with sudo
- System-wide installations
What It Checks
Schema Version
- Verifies database is at the current schema version
- Detects missing tables (e.g.,
auth,regions,dsn_cache) - Detects missing columns in existing tables
File Permissions
- Config directory (
~/.sentry) - Requires0700(owner read/write/execute only) - Database file (
config.db) - Requires0600(owner read/write only) - Journal files (
config.db-wal,config.db-shm) - Require0600
File Ownership
- Detects files owned by a different user (typically root)
- When running as root via
sudo, checks against the real user’s UID (fromSUDO_USERenvironment variable) - Skips ownership checks on Windows where
process.getuid()is unavailable
What It Repairs
Schema Repairs
- Adds missing tables - Creates tables that don’t exist in the database
- Adds missing columns - Adds columns to existing tables (with appropriate defaults)
- Never deletes data - Only additive operations are performed
Permission Repairs
- Directory first - Repairs config directory permissions before files (required for file access)
- Files in parallel - Repairs database and journal file permissions simultaneously
- Mode changes - Uses
chmodto set exact permission bits
Ownership Repairs
When running as root (viasudo):
- Transfers ownership - Uses
chownto transfer files to the real user - Resolves UID - Looks up the numeric UID for the target user
- Batch transfer - Repairs all files in parallel
- Shows instructions - Displays the exact
sudo chowncommand to run - Alternative suggested - Recommends running
sudo sentry cli fixfor automatic repair
Exit Codes
- 0 - Success (all issues repaired or none found)
- 1 - Failure (some repairs failed or issues require manual intervention)
Security Considerations
Why Strict Permissions Matter
The CLI’s local database stores:- OAuth access tokens
- Refresh tokens
- Cached API responses
- User identity information
0700 for directory, 0600 for files) ensure these sensitive files are not readable by other users on your system.
When to Use Sudo
Only usesudo sentry cli fix when:
- Files are owned by root (the command will detect this and prompt you)
- Regular
sentry cli fixreports ownership issues
sudo for normal CLI operations - this can cause ownership issues that require sudo sentry cli fix to resolve.
Related Commands
sentry cli setup- Initial CLI configurationsentry cli upgrade- Upgrade to the latest version