🐛 fix(config): env variable substitution in package envs#3746
Merged
gaborbernat merged 2 commits intotox-dev:mainfrom Feb 18, 2026
Merged
Conversation
When get_env() was called during substitution resolution with package=False for an env already created with package=True, a duplicate config set was created due to differing cache keys. Add a secondary index keyed by env name to return existing config sets regardless of the package flag. Also fix inverted condition in clear_env that kept matching entries instead of removing them. Fixes tox-dev#3238
|
Many thanks, I can confirm this fixes the issue for all my packages! |
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.
Since tox 4.14.1, substitutions like
{envtmpdir}and{env_tmp_dir}stopped expanding in external package environment commands andpackage_glob. 🐛 This affected users withpackage = externalconfigurations, where build commands containing path substitutions would receive literal{envtmpdir}strings instead of actual paths, breaking their package builds.The root cause is in
Config.get_env(). When a package environment is first created withpackage=True, it gets cached in_key_to_conf_setwith a base-dependent key (e.g.,env_pkg_base). Later, during substitution resolution, the replacement code callsget_env()with the defaultpackage=False, producing a different cache key (e.g.,env_run_base). This creates a duplicateEnvConfigSetwithout the registered config definitions, so lookups forenv_tmp_dirfail silently and the substitution is left unexpanded. The fix adds a secondary index keyed solely by environment name, ensuringget_env()returns the existing config set regardless of thepackageflag.This also fixes an inverted condition in⚠️ The
clear_env()that was keeping matching entries instead of removing them.clear_envbug had no user-visible effect because the method is only called during env re-creation where the entire dict gets rebuilt, but it's corrected here for correctness.Fixes #3238