diff --git a/ultralytics/utils/__init__.py b/ultralytics/utils/__init__.py index 9a63d43..aae007c 100644 --- a/ultralytics/utils/__init__.py +++ b/ultralytics/utils/__init__.py @@ -568,9 +568,10 @@ def get_user_config_dir(sub_dir='Ultralytics'): raise ValueError(f'Unsupported operating system: {platform.system()}') # GCP and AWS lambda fix, only /tmp is writeable - if not is_dir_writeable(str(path.parent)): - path = Path('/tmp') / sub_dir - LOGGER.warning(f"WARNING ⚠️ user config directory is not writeable, defaulting to '{path}'.") + if not is_dir_writeable(path.parent): + LOGGER.warning(f"WARNING ⚠️ user config directory '{path}' is not writeable, defaulting to '/tmp' or CWD." + 'Alternatively you can define a YOLO_CONFIG_DIR environment variable for this path.') + path = Path('/tmp') / sub_dir if is_dir_writeable('/tmp') else Path().cwd() / sub_dir # Create the subdirectory if it does not exist path.mkdir(parents=True, exist_ok=True) @@ -578,7 +579,7 @@ def get_user_config_dir(sub_dir='Ultralytics'): return path -USER_CONFIG_DIR = Path(os.getenv('YOLO_CONFIG_DIR', get_user_config_dir())) # Ultralytics settings dir +USER_CONFIG_DIR = Path(os.getenv('YOLO_CONFIG_DIR') or get_user_config_dir()) # Ultralytics settings dir SETTINGS_YAML = USER_CONFIG_DIR / 'settings.yaml'