Skip to content

Commit 9e74f45

Browse files
committed
fix: installer permission error on macOS
This commit addresses issue #4005 where the one-line installer was failing on macOS with a PermissionError when attempting to create a directory named "None". Changes: 1. Fix external_providers_dir None handling (src/llama_stack/cli/stack/run.py) - Changed from truthy check to explicit 'is not None' check - Use Path objects directly instead of str() conversion to avoid converting None to the string "None" - Added proper error handling with descriptive messages for permission errors - Added logging when creating external providers directory 2. Improve type conversion documentation (src/llama_stack/core/stack.py) - Added comments explaining that empty strings from env var defaults are converted to None - Documented that code must check for None explicitly to avoid str(None) creating the literal string "None" Testing performed: - All unit tests pass (8/8 in test_stack_config.py) - All pre-commit hooks pass - Manual testing on Apple M4 (ARM64) with Podman - Validated that None values are handled properly without string conversion Fixes #4005
1 parent 392e01d commit 9e74f45

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/llama_stack/cli/stack/run.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,17 @@ def _run_stack_run_cmd(self, args: argparse.Namespace) -> None:
176176
try:
177177
config = parse_and_maybe_upgrade_config(config_dict)
178178
# Create external_providers_dir if it's specified and doesn't exist
179-
if config.external_providers_dir and not os.path.exists(str(config.external_providers_dir)):
180-
os.makedirs(str(config.external_providers_dir), exist_ok=True)
179+
if config.external_providers_dir is not None:
180+
ext_dir = Path(config.external_providers_dir)
181+
if not ext_dir.exists():
182+
try:
183+
logger.info(f"Creating external providers directory: {ext_dir}")
184+
ext_dir.mkdir(parents=True, exist_ok=True)
185+
except (OSError, PermissionError) as e:
186+
self.parser.error(
187+
f"Failed to create external_providers_dir '{ext_dir}': {e}\n"
188+
f"Please ensure you have write permissions or specify a different path."
189+
)
181190
except AttributeError as e:
182191
self.parser.error(f"failed to parse config file '{config_file}':\n {e}")
183192

src/llama_stack/core/stack.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@ def _convert_string_to_proper_type(value: str) -> Any:
309309
# providers config should be typed this way.
310310
# TODO: we could try to load the config class and see if the config has a field with type 'str | None'
311311
# and then convert the empty string to None or not
312+
# NOTE: Empty strings from env var defaults (e.g., ${VAR:=}) are converted to None.
313+
# Code that uses these values MUST check for None explicitly (not just truthiness)
314+
# to avoid converting None to the string "None" later.
312315
if value == "":
313316
return None
314317

0 commit comments

Comments
 (0)