Skip to content

fix(dev-env): silence the undefined XDG_CACHE_HOME warning - #1343

Merged
dekobon merged 1 commit into
mainfrom
fix/dev-venv-undefined-xdg
Aug 22, 2026
Merged

fix(dev-env): silence the undefined XDG_CACHE_HOME warning#1343
dekobon merged 1 commit into
mainfrom
fix/dev-venv-undefined-xdg

Conversation

@dekobon

@dekobon dekobon commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Follow-up to #1340. Not a behaviour bug — a warning that #1340's new
variable emits on every recursive make for anyone without
XDG_CACHE_HOME set.

Problem

212455c added

DEV_VENV := $(or $(XDG_CACHE_HOME),$(HOME)/.cache)/big-code-analysis-dev/py-venv

and line 11 of the same file sets
MAKEFLAGS += --warn-undefined-variables. Reading an unset
XDG_CACHE_HOME trips it:

Makefile:2121: warning: undefined variable 'XDG_CACHE_HOME'

The variable is unset on any system that has not opted into the XDG
cache location, which is the default on macOS and common on Linux.

Why it is easy to miss. MAKEFLAGS reaches recursive sub-makes,
not the parse that set it, so the top-level make help prints nothing
and only sub-makes warn. It is quiet exactly where you would check by
hand and loud where it matters:

Invocation Warnings
make help 0
make worktree-setup 1
make pre-commit 45

Fix

Default the variable to empty so the := expansion has something
defined to read. This is the idiom the file already uses for
BCA_SINCE a few hundred lines up, with the same reasoning:

XDG_CACHE_HOME ?=

?= only assigns when undefined, so an environment value still wins
and DEV_VENV keeps both of its intended resolutions. Verified:

XDG_CACHE_HOME DEV_VENV
unset $(HOME)/.cache/big-code-analysis-dev/py-venv
/custom/cache /custom/cache/big-code-analysis-dev/py-venv

No recipe, mount, or documented path changes; docker/README.md
already describes both cases correctly.

Verification

make pre-commitBCA_GATE: pass (gate=pre-commit), with zero
undefined variable lines in the log, down from 45.

212455c introduced `DEV_VENV := $(or $(XDG_CACHE_HOME),...)`, and
`--warn-undefined-variables` (set in MAKEFLAGS at the top of the file)
fires on that expansion whenever the variable is unset -- the common
case off XDG-configured desktops, and the default on macOS.

MAKEFLAGS reaches recursive sub-makes rather than the parse that set
it, so the top-level `make help` looks clean and only sub-makes warn.
That hides it from a casual check while making it loud in the gate:
`make worktree-setup` prints it once and a full `make pre-commit`
prints it 45 times.

Fixed with the idiom already used for BCA_SINCE a few hundred lines
up: default the variable to empty with `?=` so the `:=` expansion has
something defined to read. `?=` only assigns when undefined, so an
environment value still wins. Verified both paths -- unset resolves to
`$(HOME)/.cache/big-code-analysis-dev/py-venv`, and
`XDG_CACHE_HOME=/custom/cache` resolves to
`/custom/cache/big-code-analysis-dev/py-venv`.

`make pre-commit` -> `BCA_GATE: pass`, with zero undefined-variable
warnings in the log, down from 45.
@dekobon
dekobon merged commit 6cd04cc into main Aug 22, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant