ankitects / ankitects/anki

Empty ANKIDEV crashes startup and ANKIDEV=0 still enables development shutdown behavior

Aperta
#5,575 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
30.5k
Fork
3.2k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Anki interprets `ANKIDEV` in two incompatible ways: GUI logging parses it as an integer, while the shared `dev_mode` value is the raw environment string.

Reproduction:
1. Launch Anki with `ANKIDEV` present but empty, using an entry point that preserves the supplied environment.
2. Startup fails when logging setup evaluates `int("")`.
3. Launch with `ANKIDEV=0` instead. Logging selects normal verbosity, but the nonempty string `"0"` remains truthy for shutdown behavior.

Using an installed wheel environment and a disposable base directory (the development launcher overwrites ANKIDEV):

```sh
ANKIDEV='' /path/to/venv/bin/python -I -c 'import aqt; aqt.run()' -b /path/to/disposable-profile
```

Repeat with `ANKIDEV=0` for the inconsistent shutdown flag. The shutdown consequence is diagnosed from the flag consumers; automated regressions exercise the flag values without opening a user collection.

Expected: unset, empty, and `0` consistently disable development mode.
Actual: empty fails at startup; `0` disables debug logging but still causes normal shutdown integrity checks and backups to be skipped through `dev_mode`.

Source diagnosis: `pylib/anki/utils.py` assigns the raw string to `dev_mode`; `qt/aqt/__init__.py` separately evaluates `int(os.getenv("ANKIDEV", "0"))`. `AnkiQt._unloadCollection()` uses the shared flag to gate its integrity check and backup. Normalize the shared flag once and use it for logging as well.

Other nonempty values should retain the shared flag's existing enabled behavior. Tests can evaluate the module's startup flags in fresh globals without mutating the interpreter's shared imported module.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.