Fix greenplum_path.sh GPHOME resolution under relative symlinks#1765
Open
gfphoenix78 wants to merge 1 commit into
Open
Fix greenplum_path.sh GPHOME resolution under relative symlinks#1765gfphoenix78 wants to merge 1 commit into
gfphoenix78 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
readlinkon the script's directory and accepted the link target verbatim.readlinkreturns the symlink's target string as-is; for a relative target this leaves GPHOME as a relative path, so PYTHONPATH becomesdatabase-2.1.0/lib/pythonand 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.What does this PR do?
Type of Change
Breaking Changes
Test Plan
make installcheckmake -C src/test installcheck-cbdb-parallelImpact
Performance:
User-facing changes:
Dependencies:
Checklist
Additional Context
CI Skip Instructions