From 2d5e3a40a613225b329776ab9dbd9abcd2d24222 Mon Sep 17 00:00:00 2001 From: Alex James Date: Sun, 22 Sep 2024 18:07:21 -0500 Subject: [PATCH] Handle permission errors while generating paths on Darwin On Darwin, Nix may invoke SCons in a sandbox which lacks access to /etc/paths.d. Handle PermissionError while iterating through /etc/paths.d to support sandboxed environments such as Nix. --- CHANGES.txt | 5 +++++ RELEASE.txt | 4 ++++ SCons/Platform/darwin.py | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index b402b16110..e9f445d93a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -50,6 +50,11 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Some manpage cleanup for the gettext and pdf/ps builders. - Some clarifications in the User Guide "Environments" chapter. + From Alex James: + - On Darwin, PermissionErrors are now handled while trying to access + /etc/paths.d. This may occur if SCons is invoked in a sandboxed + environment (such as Nix). + RELEASE 4.8.1 - Tue, 03 Sep 2024 17:22:20 -0700 diff --git a/RELEASE.txt b/RELEASE.txt index 06a726ec16..1ccc056fbb 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -46,6 +46,10 @@ FIXES - Fix a problem with compilation_db component initialization - the entries for assembler files were not being set up correctly. +- On Darwin, PermissionErrors are now handled while trying to access + /etc/paths.d. This may occur if SCons is invoked in a sandboxed environment + (such as Nix). + IMPROVEMENTS ------------ diff --git a/SCons/Platform/darwin.py b/SCons/Platform/darwin.py index 381b54249d..4ab7466c60 100644 --- a/SCons/Platform/darwin.py +++ b/SCons/Platform/darwin.py @@ -46,7 +46,7 @@ def generate(env) -> None: # make sure this works on Macs with Tiger or earlier try: dirlist = os.listdir('/etc/paths.d') - except FileNotFoundError: + except (FileNotFoundError, PermissionError): dirlist = [] for file in dirlist: