fix(dev-env): silence the undefined XDG_CACHE_HOME warning - #1343
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1340. Not a behaviour bug — a warning that #1340's new
variable emits on every recursive
makefor anyone withoutXDG_CACHE_HOMEset.Problem
212455c added
and line 11 of the same file sets
MAKEFLAGS += --warn-undefined-variables. Reading an unsetXDG_CACHE_HOMEtrips it: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.
MAKEFLAGSreaches recursive sub-makes,not the parse that set it, so the top-level
make helpprints nothingand only sub-makes warn. It is quiet exactly where you would check by
hand and loud where it matters:
make helpmake worktree-setupmake pre-commitFix
Default the variable to empty so the
:=expansion has somethingdefined to read. This is the idiom the file already uses for
BCA_SINCEa few hundred lines up, with the same reasoning:XDG_CACHE_HOME ?=?=only assigns when undefined, so an environment value still winsand
DEV_VENVkeeps both of its intended resolutions. Verified:XDG_CACHE_HOMEDEV_VENV$(HOME)/.cache/big-code-analysis-dev/py-venv/custom/cache/custom/cache/big-code-analysis-dev/py-venvNo recipe, mount, or documented path changes;
docker/README.mdalready describes both cases correctly.
Verification
make pre-commit→BCA_GATE: pass (gate=pre-commit), with zeroundefined variablelines in the log, down from 45.