Migrating from DISABLE_AUTO_UPDATE to zstyle ':omz:update': which settings actually take precedence
0 reputation · 10 Sept 2022, 11:54 UTC
0 reputation · 10 Sept 2022, 11:54 UTC
I maintain a dotfiles repo with an Oh My Zsh setup that predates the zstyle-based update configuration. My .zshrc still sets DISABLE_AUTO_UPDATE="true" and UPDATE_ZSH_DAYS=7, but I want to move to the documented zstyle ':omz:update' mode and frequency keys. I am unsure how the framework treats a file that defines both the legacy variables and the new zstyle keys during the transition.
The same .zshrc is shared across machines that may run different Oh My Zsh versions, so any change must not break older installs that lack the zstyle interface entirely. I also run zsh in non-interactive contexts (cron, CI scripts), so an unexpected update prompt at shell startup is a real concern. I know updates never rewrite an existing .zshrc, so the new keys will not appear automatically.
33775 reputation · 10 Sept 2022, 20:26 UTC
When both are present, the legacy environment variables are evaluated unconditionally on every Oh My Zsh release that supports them, so DISABLE_AUTO_UPDATE="true" keeps auto-update fully disabled even if a zstyle ':omz:update' mode line sits next to it. The zstyle keys are only meaningful on versions whose update library actually reads them; older installs silently ignore the zstyle block entirely. Because the exact precedence between UPDATE_ZSH_DAYS and zstyle ':omz:update' frequency is not uniformly documented across releases, treat the variables as the safe baseline and zstyle as an enhancement — and verify on each machine rather than assuming.
The zstyle-based update configuration was introduced after the variable-based one, and the framework's update code only consults zstyle ':omz:update' ... when that conditional logic exists in your local ~/.oh-my-zsh. On a pre-zstyle install, the zstyle lines are harmless no-ops: zstyle itself is a zsh builtin and setting a style nothing reads has no effect. On current installs, the update path may privilege the zstyle mode over the legacy day-count variable. That asymmetry is exactly why a shared dotfiles repo works: the intersection of both mechanisms is "legacy variables always apply, zstyle applies where supported." Note the framework never rewrites your .zshrc, so nothing migrates the keys for you — you confirmed this already.
Keep the legacy variables as the unconditional baseline, then layer zstyle on top. Both blocks must appear before source $ZSH/oh-my-zsh.sh:
# Baseline: honored by every OMZ release
DISABLE_AUTO_UPDATE="true"
UPDATE_ZSH_DAYS=7
# Enhancement: ignored harmlessly on older releases
zstyle ':omz:update' mode disabled # or: auto / reminder
zstyle ':omz:update' frequency 7For your non-interactive constraint (cron, CI), keeping DISABLE_AUTO_UPDATE="true" unconditionally is the important line: it is the mechanism with the longest support history, so it is the one you can trust to suppress startup prompts everywhere. Setting the zstyle mode to disabled to match keeps intent consistent on newer installs rather than leaving a contradictory auto in place.
Do not guess from documentation — inspect the local copy, since each machine may differ:
omz version (or read the version marker in $ZSH).grep -n "omz:update" ~/.oh-my-zsh/lib/*.zsh ~/.oh-my-zsh/tools/*.zsh. If nothing matches, that install only honors the legacy variables.After editing, start a fresh interactive shell (exec zsh) and confirm no update prompt appears. For the non-interactive case, run zsh -i -c 'echo ok' from a cron-like context and check that startup is silent and fast. If you want to confirm which mechanism is active on a newer install, temporarily remove the legacy variables, leave only the zstyle block, and observe startup behavior — then restore the belt-and-suspenders configuration above for the shared repo.
The precise interaction when UPDATE_ZSH_DAYS and zstyle ':omz:update' frequency disagree on a current release is the least-documented part of this transition; the grep-and-read step above is the reliable way to settle it per machine. If your grep output shows precedence logic that contradicts the pattern here, that local source wins — and it would be worth noting the version where you saw it.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.