From 06fcc197a046d064ef1dbdbec8980b760e5bdbd4 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Mon, 13 Oct 2025 14:49:16 +0100 Subject: [PATCH 1/2] fix(bootstrap): resolve relative symlinks A symlink to a bootstrap script can be relative. Resolve a relative symlink target to the linkname parent directory. --- python/private/stage1_bootstrap_template.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/private/stage1_bootstrap_template.sh b/python/private/stage1_bootstrap_template.sh index a984344647..557c4a4d97 100644 --- a/python/private/stage1_bootstrap_template.sh +++ b/python/private/stage1_bootstrap_template.sh @@ -97,7 +97,13 @@ else if [[ ! -L "$stub_filename" ]]; then break fi - stub_filename=$(readlink $stub_filename) + stub_filename_target=$(readlink $stub_filename) + if [[ "$stub_filename_target" == /* ]]; then + stub_filename="$stub_filename_target" + else + stub_filename="${stub_filename%/*}/$stub_filename_target" + fi + unset stub_filename_target done echo >&2 "Unable to find runfiles directory for $1" exit 1 From 602661356743cc240ea092bab80e6ea57d969233 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Mon, 13 Oct 2025 14:57:18 +0100 Subject: [PATCH 2/2] fix(bootstrap): report dangling symlinks A user can create a dangling symlink to a Python bootstrap script. Add an explicit error for dangling symlinks to help users better diagnose. --- python/private/stage1_bootstrap_template.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/private/stage1_bootstrap_template.sh b/python/private/stage1_bootstrap_template.sh index 557c4a4d97..552fe50339 100644 --- a/python/private/stage1_bootstrap_template.sh +++ b/python/private/stage1_bootstrap_template.sh @@ -104,6 +104,10 @@ else stub_filename="${stub_filename%/*}/$stub_filename_target" fi unset stub_filename_target + if [[ ! -e "$stub_filename" ]]; then + echo >&2 "Unable to find runfiles directory for $1: dangling symlink: $stub_filename" + exit 1 + fi done echo >&2 "Unable to find runfiles directory for $1" exit 1