-
Notifications
You must be signed in to change notification settings - Fork 435
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
Runfiles should return Result
instead of panicing
#2653
Comments
Looks like this dates all the way back to b8219ac from 3 years ago. |
A I agree with @DavidZbarsky-at that offering a secondary API seems reasonable. FWIW, I really don't like how all implementations of runfiles (not just rules_rust's) fail if a file is missing for manifest-based runfiles, but succeed for directory based runfiles. This leads to an interesting consequence where directory based runfiles can use runfiles to look up directories, but manifest based ones can't. |
I'd be ok with making a breaking change for this, but at least offering an alternative would make sense - not sure how others feel... |
I'd prefer not breaking here - I think providing an alternative would make sense. Alternatively, we may want to consider bringing up with the bazel team the possibility of changing the spec so that if the file doesn't exist it returns it anyway, since it's a source of inconsistency between manifest-based runfiles and directory-based runfiles. |
I think the current state of things with the panic should be considered a critical oversight. The library itself should not make the assumption that if the |
Can you outline the behavior you expect in each case? |
Directory based runfiles just returns the path. If the file doesn't exist in the manifest, then path.is_file will return false, but the command will still succeed |
I have created #2847 which converts panics to |
I haven't been keeping up too closely with the recent changes to runfiles but I wanna make sure the interface doesn't have panics in it and that we allow users to handle results at runtime.
https://github.com/bazelbuild/rules_rust/blob/0.44.0/tools/runfiles/runfiles.rs#L146-L155
This seems concerning. In practice does it not ever get hit?
The text was updated successfully, but these errors were encountered: