Skip to content

Default child environment: HOME is not forwarded and a PATH change re-runs nothing, neither pinned by a requirement #480

Description

@typeless

Symptom

putup's default child environment diverges from tup's default_env[] in two ways that no requirement in spec/requirements/ states, so a reader diffing against upstream finds them as defects rather than decisions.

  1. HOME is not forwarded. tup's default_env[] (src/tup/environ.c) is PATH and HOME on POSIX, plus a Visual Studio set under _WIN32. putup's base_child_env() (src/platform/process-posix.cpp) gives PATH, and since Build commands get PATH only, so TMPDIR is dropped and GCC writes temporaries into the source tree when /tmp is read-only #478 TMPDIR/TMP/TEMP when set. A probe rule : |> echo "HOME=[$HOME]" > %o |> out.txt prints HOME=[] under putup. Tools that resolve per-user state from HOME (ccache is why tup forwards it, and tup also injects CCACHE_NODIRECT=1 in tup_db_get_environ) fall back to getpwuid or fail; which tools break is not measured.

  2. A PATH change re-runs nothing. tup makes every default-environment name a sticky env node of each command (environ_add_defaults, tup_db_check_env), so a changed PATH re-runs every command; the man page says so under export. putup forwards PATH without recording it. Reproduced on main 75c93ee with : |> echo "PATH=$PATH" > %o |> out.txt: build with PATH=/usr/bin:/bin, rebuild with PATH=/usr/bin:/bin:/opt/zzz, putup prints Nothing to do (up to date) and out.txt keeps the first value. The only route by which PATH reaches identity is CONFIG_TRACKED_TOOLS resolving a bare name through it.

Where this stands in the spec

#479 added REQ-ENV-TEMPDIR and REQ-ENV-TEMPDIR-IDENTITY for the temporary-directory variables and noted the HOME divergence in a reference: clause only. PATH's forwarded-not-recorded status has no requirement; docs/reference.md §export now states it in prose.

Decisions to make

  • Whether to forward HOME (conform to tup) or declare its absence as a deviation with a requirement. If forwarded, whether it joins identity: the same per-session concern that kept TMPDIR out applies less (a user's HOME rarely changes between builds), but tup's behaviour of re-running on any default-variable change is what a tup-conformant label would have to mean.
  • Whether PATH changes should re-run commands as in tup, or stay excluded with a requirement stating so and naming CONFIG_TRACKED_TOOLS as the deliberate route. Re-running on every PATH change is the tup behaviour the man page warns about ("if PATH is changed, all commands will run again").

Either way the outcome is a requirement per variable in command-record.ears.md's env-values group with a discharging scenario, so the divergence stops being silent.

Found by the #478 design and review passes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions