diff --git a/poethepoet/env/manager.py b/poethepoet/env/manager.py index e9c478afd..d5658bb0a 100644 --- a/poethepoet/env/manager.py +++ b/poethepoet/env/manager.py @@ -116,6 +116,7 @@ def apply_env_config( self._vars[key] = apply_envvars_to_template( value_str, scoped_env, require_braces=True ) + scoped_env.set(key, self._vars[key]) def update(self, env_vars: Mapping[str, Any]): # ensure all values are strings diff --git a/tests/test_env_config.py b/tests/test_env_config.py index 9d9a2e5ab..a0416002c 100644 --- a/tests/test_env_config.py +++ b/tests/test_env_config.py @@ -32,3 +32,23 @@ def test_global_env_templating(temp_pyproject, run_poe_subproc): } for value in printed_vars.values(): assert value.endswith(str(project_path)[5:]) + + +EXAMPLE_WITH_ENV_COMPOSITION = """ +[tool.poe.env] +BASE_DIR = "/foo" +SUBDIR = "${BASE_DIR}/bar" +FILE = "${SUBDIR}/baz" + +[tool.poe.tasks.frobnicate] +expr = "${FILE}" +""" + + +def test_substitution_in_envvar(temp_pyproject, run_poe_subproc): + project_path = temp_pyproject(EXAMPLE_WITH_ENV_COMPOSITION) + result = run_poe_subproc("frobnicate", cwd=project_path) + + assert result.capture == "Poe => ${FILE}\n" + assert result.stdout == "/foo/bar/baz\n" + assert result.stderr == ""