The answer is related to Doom Emacs. I should have included in my original question that I was using a Doom config.
The reason my initial attempt at putting a debug-on-variable-change
in my init.el
didn't work was because I was putting it in .doom.d/init.el
which is loaded late in the initialization process. After reading the Doom docs about the initialization order, I saw that it starts with .emacs.d/init.el
(of course). I put the debug-on-variable-change
in there and saw it was happening in the function (doom-load-envvars-file "~/.emacs.d/.local/env")
which gets called as part of Doom's initialization.
# -*- mode: sh -*-
# Generated from a /bin/zsh shell environent
# ---------------------------------------------------------------------------
# This file was auto-generated by `doom env'. It contains a list of environment
# variables scraped from your default shell (excluding variables blacklisted
# in doom-env-ignored-vars).
#
# It is NOT safe to edit this file. Changes will be overwritten next time you
# run 'doom sync'. To create a safe-to-edit envvar file use:
#
# doom env -o ~/.doom.d/myenv
#
# And load it with (doom-load-envvars-file "~/.doom.d/myenv").
# ---------------------------------------------------------------------------
I just needed to run doom sync
from a terminal that had the environment that I wanted.