Skip to content

[BUG] [v0.0.7] cortex update subsystem ignores CORTEX_HOME and writes update.json/update_cache.json under ~/.cortex #53527

@DDDDDGCSM

Description

@DDDDDGCSM

Project

cortex

Description

The update subsystem ignores CORTEX_HOME and uses HOME/.cortex for both persistent update files:

  • update_cache.json from the upgrade check path
  • update.json from the update config path

This creates split state. The CLI help explicitly documents CORTEX_HOME as the config directory override, but the update subsystem bypasses it and writes under ~/.cortex instead.

Error Message

No explicit error is shown. The bug is silent state being written to the wrong directory.

Debug Logs

HOME=/tmp/cortex-repro-home CORTEX_HOME=/tmp/cortex-repro-config /tmp/cortex-bin/Cortex upgrade --check --yes --channel stable

✓ You are already on the latest version (v0.0.7)

find /tmp/cortex-repro-home /tmp/cortex-repro-config -maxdepth 4 -type f -o -type d | sort
/tmp/cortex-repro-config
/tmp/cortex-repro-home
/tmp/cortex-repro-home/.cortex
/tmp/cortex-repro-home/.cortex/update_cache.json

System Information

macOS Darwin 25.x (Apple Silicon)
Cortex CLI v0.0.7
Rust toolchain: cargo 1.95.0 / rustc 1.95.0

Screenshots

Prepared evidence image showing both the runtime repro and the targeted update-config proof:

/tmp/cortex-cortexhome-bug-evidence-clean.png

Steps to Reproduce

  1. Set HOME and CORTEX_HOME to different directories.
  2. Run:
    HOME=/tmp/cortex-repro-home CORTEX_HOME=/tmp/cortex-repro-config cortex upgrade --check --yes --channel stable
  3. Inspect both directories.
  4. Observe that update_cache.json is created under HOME/.cortex/update_cache.json and nothing is written under CORTEX_HOME.
  5. For the config-writing path, run the targeted proof:
    cargo test -p cortex-update --test update_config_home_override -- --test-threads=1 --nocapture
  6. Observe the test passes only because UpdateManager::skip_version() writes update.json under HOME/.cortex/update.json and not under CORTEX_HOME/update.json.

Expected Behavior

All update subsystem state should respect the active Cortex home override. If CORTEX_HOME is set, both:

  • update_cache.json
  • update.json

should be stored under that override rather than hardcoded HOME/.cortex.

Actual Behavior

The update subsystem uses dirs::home_dir().join(".cortex") directly:

  • UpdateConfig::load() / save() use HOME/.cortex/update.json
  • VersionCache uses HOME/.cortex/update_cache.json

As a result, update-related state is split away from the configured Cortex home.

Additional Context

Relevant source paths:

  • src/cortex-update/src/config.rs
    • UpdateConfig::load() uses dirs::home_dir().join(".cortex").join("update.json")
    • UpdateConfig::save() writes to dirs::home_dir().join(".cortex").join("update.json")
  • src/cortex-update/src/version.rs
    • VersionCache uses dirs::home_dir().join(".cortex").join("update_cache.json")
  • src/cortex-cli/src/upgrade_cmd.rs
    • UpgradeCli::run() creates config via UpdateConfig::load()
  • src/cortex-update/src/manager.rs
    • check_update_forced() writes the cache
    • skip_version() / clear_skip() write update.json

This is adjacent to, but not the same as, #51572 ("Config command ignores custom Cortex home path"). That issue is about the config command handler. This report is specifically about the cortex-update subsystem using its own hardcoded HOME/.cortex paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions