Fix Makefile bare export leaking all variables to subprocesses#4653
Fix Makefile bare export leaking all variables to subprocesses#4653tuxerrante wants to merge 1 commit into
Conversation
mrWinston
left a comment
There was a problem hiding this comment.
Couple of things:
- I believe sourcing the env file automatically in the Makefile is conceptually flawed. It just increases complexity of our make-targets. Targets can't assume anymore that the caller has already sourced the required env file. Also, using different env files will be more complex.
- It looks like this PR reorders stuff in the env file without reason. This makes reviewing harder and actually introduced a bug. Please make sure that the changes are actually minimal.
- This RP seems to add additional configuration to the default env file. I would like to see this in a separate PR to address these changes separately. They don't seem related to the issue ourlined in the PR title and make reviewing harder
- Adding the env file to git can cause issues overwriting existing local configuration. Also, having a file both ignored and added is pretty confusing and surprising. And both are bad for our dev tooling.
afa4a52 to
51becbd
Compare
|
A few clarifications:
Tried with shellcheck but doesn't catch it. It sees that LOCATION is assigned somewhere in the file and considers it valid. It doesn't do order-sensitive analysis because the variable could also come from the environment. |
|
Please rebase pull request. |
Remove `-include .env` and bare `export` which leaked every Make variable into recipe shells. Replace with a scoped `PYTHONPATH ?=` default so Python targets work without manual sourcing. Add PYTHONPATH to env.example for discoverability.
51becbd to
66d503c
Compare
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce make overhead and unexpected behavior by stopping GNU Make from exporting all Make variables into every subprocess environment, and by consolidating the Python PYTHONPATH setup into the standard env workflow.
Changes:
- Removed the bare
exportdirective from the Makefile and replaced it with an explicitPYTHONPATHexport only. - Added
PYTHONPATHtoenv.exampleso contributors get the Python path when creating/sourcing their localenvfile.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Makefile | Removes bare export and explicitly exports only PYTHONPATH with a default value. |
| env.example | Adds PYTHONPATH so local env files created from the example include the needed Python module path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
exportdirective from the Makefile that was exporting every Make variable into the environment of every subprocess, causing potential slowness and unexpected behavior.envfile (containing onlyPYTHONPATH) into the existingenvfile andenv.exampleWhy some contributors experienced multi-minute make invocations
The bare
exportexported all Make variables — including ones defined with recursive expansion (=,?=) containing$(shell)calls (git describe,git rev-parse,go env, etc.) — to every subprocess. Contributors with heavier shell startup (zsh + oh-my-zsh/compinit, nvm, conda) paid that cost on each$(shell)invocation. On fast setups with minimal bash the overhead was imperceptible, masking the issue.The
tunneltarget also used$(shell az ...)which ranazat Makefile parse time on everymakeinvocation, not just whenmake tunnelwas called. This is now a recipe-level$$(az ...)call.Test plan
makecommands expect you to manually source theenvfile as per the docs