-
Notifications
You must be signed in to change notification settings - Fork 8
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
Report io error when detect cannot read a file. #243
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
schneems
force-pushed
the
schneems/fs_err_try_exists
branch
from
November 28, 2023 22:52
633c036
to
ec7f3f8
Compare
It's best practice to use `try_exists()` instead of `exists()` when checking if a file exists or not because if there's a problem with the file (such as a permissions issue) then the check might fail even though the file is on disk. This seems like not a big deal, but can be very confusing when telling users "we didn't do X because you are missing file Y" but when they debug they see file Y and don't realize that the real problem isn't "missing file" but it's the hidden error preventing `exists()` from returning a true. This commit uses fs_err_try_exists() from fs-err library that was introduced in: andrewhickman/fs-err#48. There are a few other places where `exists` is still called, those are nested in areas that don't already return a Result so they're harder to swap.
schneems
force-pushed
the
schneems/fs_err_try_exists
branch
from
November 29, 2023 17:53
ec7f3f8
to
21577a2
Compare
colincasey
requested changes
Nov 30, 2023
Explanation from colin: If you kept the text as it, it could break too early and leave a lot of whitespace: ``` The Ruby buildpack detected a package.json file but it is not readable | <- term width due to the following errors: | ``` This is sometimes okay. or the worse case is a small terminal where it breaks too late and causes weird wrapping: ``` The Ruby buildpack detected a package.json file but | <- term width it is not readable | due to the following errors: | ``` --- Richard: I agree this is a sub-optimal experience. We should use double newline to indicate paragraphs and let the terminal handle wrapping for us within the paragraph. I'm unsure of how this will interact with colorized output as it might color the `remoteL` annotations. Either that or the indentation won't align. I'm not sure how different terminals handle that case. Trying it out it looks like this: ``` $ cat bin/detect #!/usr/bin/env bash echo "Worked" ⛄️ 3.1.4 🚀 /tmp/8efcb3e683a408206c4c8f017697f813 (main) $ cat bin/compile #!/usr/bin/env bash echo -e "\e[0;31mhihihihihihihihihihi hihihihihihihihihihihihihihihi hihihihihihihi hi hihihihihihihihihi hihihihihihihihihihi hihihihihihi hihihihihihihihihihi hihihihihihihihihi hihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihi hihihi\e[0m" ⛄️ 3.1.4 🚀 /tmp/8efcb3e683a408206c4c8f017697f813 (main) $ heroku buildpacks === immense-beyond-95949 Buildpack URL heroku-community/inline ``` ``` $ git push Enumerating objects: 7, done. Counting objects: 100% (7/7), done. Delta compression using up to 12 threads Compressing objects: 100% (4/4), done. Writing objects: 100% (7/7), 482 bytes | 482.00 KiB/s, done. Total 7 (delta 0), reused 0 (delta 0), pack-reused 0 remote: Updated 3 paths from e061d88 remote: Compressing source files... done. remote: Building source: remote: remote: -----> Building on the Heroku-22 stack remote: -----> Using buildpack: heroku-community/inline remote: -----> Worked app detected remote: hihihihihihihihihihi hihihihihihihihihihihihihihihi hihihihihihihi hi hihihihihihihihihi hihihihihihihihihihi hihihihihihi hihihihihihihihihihi hihihihihihihihihi hihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihi hihihi remote: -----> Discovering process types remote: Procfile declares types -> (none) remote: remote: -----> Compressing... remote: Done: 320B remote: -----> Launching... remote: Released v3 remote: https://immense-beyond-95949-a2b498662b8a.herokuapp.com/ deployed to Heroku remote: remote: Verifying deploy... done. To https://git.heroku.com/immense-beyond-95949.git * [new branch] main -> main ``` It looks like this: https://imgur.com/a/sOscF4m Co-authored-by: Colin Casey <[email protected]>
colincasey
approved these changes
Jan 15, 2024
This was referenced Mar 18, 2024
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It's best practice to use
try_exists()
instead ofexists()
when checking if a file exists or not because if there's a problem with the file (such as a permissions issue) then the check might fail even though the file is on disk. This seems like not a big deal, but can be very confusing when telling users "we didn't do X because you are missing file Y" but when they debug they see file Y and don't realize that the real problem isn't "missing file" but it's the hidden error preventingexists()
from returning a true.This commit uses fs_err_try_exists() from fs-err library that was introduced in: andrewhickman/fs-err#48.
There are a few other places where
exists
is still called, those are nested in areas that don't already return a Result so they're harder to swap.