Skip to content

fix: isolate PyInstaller library paths for subprocess calls#8628

Open
dcabib wants to merge 1 commit intoaws:developfrom
dcabib:fix/pyinstaller-library-path-isolation
Open

fix: isolate PyInstaller library paths for subprocess calls#8628
dcabib wants to merge 1 commit intoaws:developfrom
dcabib:fix/pyinstaller-library-path-isolation

Conversation

@dcabib
Copy link

@dcabib dcabib commented Feb 4, 2026

Description

When SAM CLI runs from the native installer (PyInstaller-based), it sets LD_LIBRARY_PATH/DYLD_LIBRARY_PATH to include bundled libraries. This causes conflicts when spawning external processes like npm, node, or pip that need system libraries (e.g., OpenSSL version mismatch on Fedora 43).

Changes

  • Added isolate_library_paths_for_subprocess() function to subprocess_utils.py
  • Detects PyInstaller bundle via sys._MEIPASS
  • Filters bundled library paths from environment variables early in CLI initialization

Testing

  • 20 unit tests added, all passing (6907 total)
  • Code coverage: 94%

Fixes #8542

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

When SAM CLI runs from the native installer (PyInstaller-based), it sets
LD_LIBRARY_PATH/DYLD_LIBRARY_PATH to include bundled libraries. This causes
conflicts when spawning external processes like npm, node, or pip that need
system libraries (e.g., OpenSSL version mismatch on Fedora 43).

This change:
- Detects PyInstaller bundle via sys._MEIPASS
- Filters bundled library paths from environment variables early in CLI init
- Ensures external processes use system libraries instead of bundled ones

Fixes aws#8542
@dcabib dcabib requested a review from a team as a code owner February 4, 2026 17:26
@github-actions github-actions bot added pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Feb 4, 2026
Copy link
Contributor

@bnusunny bnusunny left a comment

Choose a reason for hiding this comment

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

Thanks for this nice PR @dcabib! Just a minor issue to check.


# Filter out paths that are inside the PyInstaller bundle
filtered_paths = [
p for p in paths if not p.startswith(meipass) and "_internal" not in p and "dist/_internal" not in p
Copy link
Contributor

Choose a reason for hiding this comment

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

The current filtering logic might be slightly too broad. The "_internal" not in p check could theoretically filter legitimate system paths containing "_internal". Consider making it more specific:

filtered_paths = [
    p for p in paths 
    if not (p.startswith(meipass) or 
            p.endswith("/_internal") or 
            "dist/_internal" in p)
]

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

Labels

pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: SAM build fails with a broken openssl dependency after upgrading to Fedora 43

2 participants