-
Notifications
You must be signed in to change notification settings - Fork 697
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
Add check on project root file and fail if broken link #10103
Conversation
I don't think it's particularly valuable to add a changelog for this, but let me know if you think otherwise |
It's still a user-visible change, and entirely possible that someone relies on the old behavior (granting that that's relying on a bug, but https://xkcd.com/1172/). |
Confirmed working on Windows: CMD> mklink cabal.project I-do-not-exist
symbolic link created for cabal.project <<===>> I-do-not-exist ➜ rm I-do-not-exist
➜ ls -lah cabal.project
lrwxrwxrwx 1 Javier Javier 4 Jul 22 23:53 cabal.project -> I-do-not-exist
➜ $CABAL build
Warning: this is a debug build of cabal-install with assertions enabled.
The given project file 'cabal.project' is broken. Is it a broken symbolic link? |
This is my first PR on Cabal, and I'm not sure how the process works (I couldn't find any information in the CONTRIBUTING file). Should I rebase it periodically? Am I missing anything to get this PR reviewed? |
Hey @albertodvp! I'm sorry you had to wait for so long. Don't worry about rebasing. We just need to get around to reviewing your PR: two approvals are necessary. I prodded people on Matrix, so, hopefully, this can be done this or next week. After two approvals we'll see how to proceed. |
Usually the
|
Thank you! I did add some tests, I'm happy to add others if you have some requests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Little things.
Strictly speaking, this is a race condition. It doesn't really matter in this case, though; you just gets suboptimal messaging.
let isUsableAciton = | ||
handle @IOException | ||
-- NOTE: if any IOException is raised, we assume the file does not exist. | ||
-- That is what happen when we call @pathIsSymbolicLink@ on an @FilePath@ that does not exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- That is what happen when we call @pathIsSymbolicLink@ on an @FilePath@ that does not exist. | |
-- That is what happen when we call @pathIsSymbolicLink@ on a @FilePath@ that does not exist. |
-- That is what happen when we call @pathIsSymbolicLink@ on an @FilePath@ that does not exist. | ||
(const $ pure False) | ||
((||) <$> pathIsSymbolicLink filePath <*> doesPathExist filePath) | ||
isUnusable <- isUsableAciton |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isUnusable <- isUsableAciton | |
isUnusable <- isUsableAction |
if exists | ||
then return ProjectRootUsabilityPresentAndUsable | ||
else do | ||
let isUsableAciton = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let isUsableAciton = | |
let isUsableAction = |
Thank you for the review! |
It's the very concept: checking something before use instead of at the time of use; in this case, that would be reporting why opening the project file in one of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thanks!
The next step would be setting a merge label when the author is happy with the PR and there are no lingering discussions. |
9fe7e37
to
f4fbcf4
Compare
" (I thought this might be a problem with #10260 at first, but (a) we've had successful merges since then (b) Mergify's log says this also happened on 27 July which was well before #10260.) |
Hi @geekosaur - I've just rebased and force-pushed. I hope that was ok |
Yes, that's fine and probably what it needed. Mergify's been being a bit weird of late for some reason; it doesn't like something that's in |
This PR modifies behaviour or interface**
Include the following checklist in your PR:
QA Notes
Build patched version
Reproduce
Not patched version
Expected behavour: cabal ignores the broken link and builds the project (ignoring the
cabal.project
and not signaling anything)Patched version
Then, slighly adapting the example provided in the issue
Expected behavour: cabal should exit with status code
1
and should print:Resolves #9937