Fix depot_tools python3 bootstrap: update_depot_tools refuses to run as root

Root cause of the python3_bin_reldir.txt failures (ci runs #54, #55):
depot_tools/update_depot_tools has an explicit guard --
"Running depot tools as root is sad" -- and no-ops entirely when $USER is
root, which we always are on the ephemeral build box. gclient itself
still works because it goes through vpython3 (separately bootstrapped),
but the plain python3 wrapper's bootstrap file never gets created via
that path.

Fix: call the two functions update_depot_tools invokes after its root
check (cipd_bin_setup, bootstrap_python3) directly, sidestepping the
check. Verified end-to-end against a real ephemeral box: file gets
created, `depot_tools/python3 --version` succeeds as root.
This commit is contained in:
Philip Peterson 2026-08-04 12:40:29 -08:00
parent a084710b65
commit c360590e5f

33
sync.sh
View file

@ -36,15 +36,30 @@ if [ ! -d "$HOME/depot_tools" ]; then
fi
export PATH="$HOME/depot_tools:$PATH"
# Explicit bootstrap before anything else touches python3. depot_tools'
# `python3` wrapper needs python3_bin_reldir.txt, normally created on first
# use -- but chromium's own gclient hooks run
# update_depot_tools_toggle.py --disable partway through sync (confirmed:
# ci run #54, 2026-08-04), which can win the race and leave that file
# missing for any *later* direct python3 invocation, e.g.
# install-build-deps.py's shebang in the next phase. Forcing the bootstrap
# here, before sync even starts, sidesteps the race entirely.
"$HOME/depot_tools/python3" --version >/dev/null
# Explicit bootstrap before anything else touches depot_tools' `python3`
# wrapper. That wrapper hard-requires python3_bin_reldir.txt (see
# depot_tools/python3), which is normally created by `update_depot_tools`
# -- but update_depot_tools itself refuses to do anything as root
# ("Running depot tools as root is sad", see depot_tools/update_depot_tools)
# and we're root on this box. gclient sync still works without this
# (confirmed: ci run #54, 2026-08-04, sync completed fully) because it goes
# through vpython3, a separately-bootstrapped wrapper -- but any later
# direct python3 invocation, e.g. install-build-deps.py's shebang, fails
# with exactly this error otherwise. cipd_bin_setup and bootstrap_python3
# are the two functions update_depot_tools calls after its root check;
# calling them straight sidesteps that check entirely.
#
# set +u around this block: these are third-party scripts (depot_tools'
# own cipd/cipd_bin_setup.sh), not written to be safe under nounset --
# confirmed cipd itself references an unset var with no default and dies
# under set -u. They're sourced (not exec'd), so they inherit our shell's
# flags; restore -u immediately after.
set +u
source "$HOME/depot_tools/cipd_bin_setup.sh"
cipd_bin_setup
source "$HOME/depot_tools/bootstrap_python3"
bootstrap_python3
set -u
mkdir -p "$CHROMIUM_ROOT"
cd "$CHROMIUM_ROOT"