diff --git a/src/huggingface_hub/utils/_hf_folder.py b/src/huggingface_hub/utils/_hf_folder.py index 5335769313..5c9f07c9ba 100644 --- a/src/huggingface_hub/utils/_hf_folder.py +++ b/src/huggingface_hub/utils/_hf_folder.py @@ -57,7 +57,10 @@ def get_token(cls) -> Optional[str]: `str` or `None`: The token, `None` if it doesn't exist. """ # 0. Check if token exist in old path but not new location - cls._copy_to_new_path_and_warn() + try: + cls._copy_to_new_path_and_warn() + except Exception: # if not possible (e.g. PermissionError), do not raise + pass # 1. Is it set by environment variable ? token: Optional[str] = os.environ.get("HUGGING_FACE_HUB_TOKEN")