This is an automated email from the ASF dual-hosted git repository.
gfphoenix78 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/main by this push:
new c69257369c8 Fix greenplum_path.sh GPHOME resolution under relative
symlinks
c69257369c8 is described below
commit c69257369c84b4caae23dea05b48c3bc7573adbb
Author: Hao Wu <[email protected]>
AuthorDate: Tue May 26 02:21:52 2026 +0000
Fix greenplum_path.sh GPHOME resolution under relative symlinks
When GPHOME is reached via a symlink whose target is stored as a
relative path (e.g. /opt/database -> database-2.1.0), the previous
logic ran a bare `readlink` on the script's directory and accepted
the link target verbatim. `readlink` returns the symlink's target
string as-is; for a relative target this leaves GPHOME as a relative
path, so PYTHONPATH becomes `database-2.1.0/lib/python` and gpstart
fails with ModuleNotFoundError: No module named 'gppylib' the moment
the shell's cwd is anything other than the symlink's parent.
Replace the symlink-vs-not branch with a single `pwd -P`, which
resolves every symlink component and returns the canonical absolute
path regardless of how the user reached the directory. This also
removes the unnecessary `[ -L ... ]` test and the dependency on GNU
readlink semantics.
---
gpMgmt/bin/generate-cloudberry-env.sh | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/gpMgmt/bin/generate-cloudberry-env.sh
b/gpMgmt/bin/generate-cloudberry-env.sh
index 7f1f9074efc..0eca71b4884 100755
--- a/gpMgmt/bin/generate-cloudberry-env.sh
+++ b/gpMgmt/bin/generate-cloudberry-env.sh
@@ -17,13 +17,15 @@ fi
if test -z "$SCRIPT_PATH"; then
echo "The shell cannot be identified. \$GPHOME may not be set correctly."
>&2
fi
-SCRIPT_DIR="$(cd "$(dirname "${SCRIPT_PATH}")" >/dev/null 2>&1 && pwd)"
-if [ ! -L "${SCRIPT_DIR}" ]; then
- GPHOME=${SCRIPT_DIR}
-else
- GPHOME=$(readlink "${SCRIPT_DIR}")
-fi
+# downstream PATH / PYTHONPATH / LD_LIBRARY_PATH derivations stay valid
+# even when GPHOME is reached via a symlink whose target is a relative
+# path (e.g. /opt/database -> database-2.1.0). `pwd -P` resolves every
+# symlink component, returning the physical absolute path. This replaces
+# an earlier branch that ran bare `readlink` on the script's directory,
+# which would return the symlink target verbatim and break with relative
+# targets (PYTHONPATH became relative, gppylib import failed).
+GPHOME="$(cd "$(dirname "${SCRIPT_PATH}")" >/dev/null 2>&1 && pwd -P)"
EOF
cat <<"EOF"
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]