Skip to content

Commit ed2e3b9

Browse files
authored
Merge pull request #36 from tomaarsen/hotfix/os_error_name_too_long
Fixes `OSError: File name too long` when environment variable is too long
2 parents 76699b4 + 7d771d1 commit ed2e3b9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

bitsandbytes/cuda_setup/paths.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import errno
12
from pathlib import Path
23
from typing import Set, Union
34
from warnings import warn
@@ -12,17 +13,23 @@ def extract_candidate_paths(paths_list_candidate: str) -> Set[Path]:
1213

1314

1415
def remove_non_existent_dirs(candidate_paths: Set[Path]) -> Set[Path]:
15-
non_existent_directories: Set[Path] = {
16-
path for path in candidate_paths if not path.exists()
17-
}
18-
16+
existent_directories: Set[Path] = set()
17+
for path in candidate_paths:
18+
try:
19+
if path.exists():
20+
existent_directories.add(path)
21+
except OSError as exc:
22+
if exc.errno != errno.ENAMETOOLONG:
23+
raise exc
24+
25+
non_existent_directories: Set[Path] = candidate_paths - existent_directories
1926
if non_existent_directories:
2027
warn(
2128
"WARNING: The following directories listed in your path were found to "
2229
f"be non-existent: {non_existent_directories}"
2330
)
2431

25-
return candidate_paths - non_existent_directories
32+
return existent_directories
2633

2734

2835
def get_cuda_runtime_lib_paths(candidate_paths: Set[Path]) -> Set[Path]:

0 commit comments

Comments
 (0)