Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes OSError: File name too long when environment variable is too long #36

Conversation

tomaarsen
Copy link
Contributor

Resolves #35

Hello!

Pull request overview

  • Fixes OSError: File name too long when environment variable is too long by try-catching for an OSError, and ignoring it when it causes an error due to File name too long.

Details

This PR complies with the EAFP "easier to ask for forgiveness than permission" style as recommended in the Python glossary. It simply writes out the set comprehension in full and wraps each path.exists() call with a try-except which simply considers a candidate path to be non-existent whenever it throws File name too long.

After this PR, the output of the same program as #35 outputs only

...
bitsandbytes/cuda_setup/paths.py:27: UserWarning: WARNING: The following directories listed in your path were found to be non-existent: {PosixPath('-};\n do\n if [ "${_m [[removed]]
...

This is the expected behaviour here.

Lastly, the changes should be equivalently efficient as before.

Note

It may be possible that path.exists() can throw other exceptions that maybe should be ignored as well, but this PR only ignores the File name too long exception.

Let me know if you need anything from me at this point!

  • Tom Aarsen

@TimDettmers
Copy link
Collaborator

Perfect issue and pull request. Thank you for the explanation and the work!

@TimDettmers TimDettmers merged commit ed2e3b9 into bitsandbytes-foundation:main Oct 9, 2022
@tomaarsen tomaarsen deleted the hotfix/os_error_name_too_long branch October 10, 2022 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OSError: File name too long when environment variable is too long
2 participants