Skip to content

Fix greenplum_path.sh GPHOME resolution under relative symlinks#1765

Open
gfphoenix78 wants to merge 1 commit into
apache:mainfrom
gfphoenix78:fix-env
Open

Fix greenplum_path.sh GPHOME resolution under relative symlinks#1765
gfphoenix78 wants to merge 1 commit into
apache:mainfrom
gfphoenix78:fix-env

Conversation

@gfphoenix78
Copy link
Copy Markdown
Contributor

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.

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


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.
Copy link
Copy Markdown
Contributor

@my-ship-it my-ship-it left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants