-
Notifications
You must be signed in to change notification settings - Fork 685
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
Prompt overwrite policy #5672
Prompt overwrite policy #5672
Conversation
"url":"pull/5672", "account":"haskell", "repo":"cabal", "commit": "f459bb10c1e75c425bdb8acdce892d00a231aed5", "tag":"linux-7.10.3" }
"url":"pull/5672", "account":"haskell", "repo":"cabal", "commit": "f459bb10c1e75c425bdb8acdce892d00a231aed5", "tag":"linux-8.0.2" }
See #5644. |
"url":"pull/5672", "account":"haskell", "repo":"cabal", "commit": "f459bb10c1e75c425bdb8acdce892d00a231aed5", "tag":"linux-8.2.2" }
"url":"pull/5672", "account":"haskell", "repo":"cabal", "commit": "f459bb10c1e75c425bdb8acdce892d00a231aed5", "tag":"linux-8.4.3" }
"url":"pull/5672", "account":"haskell", "repo":"cabal", "commit": "f459bb10c1e75c425bdb8acdce892d00a231aed5", "tag":"linux-8.4.3-fdebug-expensive-assertions" }
"url":"pull/5672", "account":"haskell", "repo":"cabal", "commit": "f459bb10c1e75c425bdb8acdce892d00a231aed5", "tag":"osx-8.0.2" }
"url":"pull/5672", "account":"haskell", "repo":"cabal", "commit": "f459bb10c1e75c425bdb8acdce892d00a231aed5", "tag":"osx-7.10.3" }
/cc @hvr |
@23Skidoo I haven't yet looked at this in detail, but this is exactly the kind of overwrite policies I had in mind :-) What I'm a bit unsure about though is how we can model interactivity into a future abstracted UI I/O layer (that thing for which the big "Cabal Monad" refactoring represents a pre-req) ... (but this isn't a blocker for this PR -- just something this reminds me of) |
f459bb1
to
e61b60d
Compare
I've changed the PR to target |
I hope this can be picked up and worked on, seems like it is a nice ux improvement that everyone is on board with. |
@fgaz can you try to resolve the conflict here? This looks like something we should make happen... |
e61b60d
to
f3f89d5
Compare
I resolved the conflict, but the copy+prompt case is not handled. I left a TODO, if someone wants to finish this. |
Also sorry for force-pushing @fredefox, I remembered too late that this wasn't my branch (github kept the old ref archived though) |
@fredefox: thank you for your work so far. Would you like to add the missing case or are you busy ATM? |
Given that @fredefox seems busy, I'm opening this PR to a rescue operation by any noble volunteers. Please feel free to overwrite this branch (or create a new PR if you insist). |
Sorry @Mikolaj. Forgot to reply. My GitHub inbox is super swamped. I don't know if I'll look at this any time soon. Anyone should indeed feel free to take this over. |
f3f89d5
to
7a4ba21
Compare
I've updated the PR. I seem to have some laziness/buffering-issue. The prompt is not displayed before hitting enter after which a parse-error is also printed. I might return to it later. Other people are still invited to contribute patches on top of this. I was unsure what heading to put my change under in the change log. |
7a4ba21
to
9be9bb7
Compare
@fredefox: hi! may I help to get this PR merged before it rots? :) |
Hi @Mikolaj. Feel free to take over. There is a remaining issue with my work. The prompt is not displayed eagerly enough. I'm not sure why. I suggest testing this, as I did, by running |
b06b9e5
to
1d163d1
Compare
@fredefox: got it. No pressure. Thanks for sharing the problem --- perhaps somebody takes a look and gets a hunch as to why this happens, before you return. |
b06b9e5
to
9882a8d
Compare
Hi @Mikolaj. I found the issue and I wrote a solution to it. Emphases on "a". Perhaps someone might have a better proposal than what I did. I figured out that in
The output does indeed appear before blocking for input. Perhaps some strange interaction from the Anyways. In summation, the PR is ready to go as-is as far as I can see. |
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.
I don't have an explanation, but I'm not surprised at all. I routinely flush whenever I finish adding to the displayed text.
@Mergifyio rebase |
35da53a
to
ae461cf
Compare
✅ Branch has been successfully rebased |
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.
Couple of changes, but it looks good overall. :)
overwrite :: IO Bool | ||
overwrite = remove >> copy | ||
maybeOverwrite :: IO Bool | ||
maybeOverwrite = do | ||
a <- promptYesNo | ||
"Existing file found while installing executable. Do you want to unlink that file? (y/n)" | ||
MandatoryPrompt | ||
if a then overwrite else pure a |
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.
You're doing this work twice, here and in InstallSymlink.hs
. Could this maybe be unified? :)
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.
I think it definitely might be able to do some refacturing to increase sharing between installBuiltExe
and symlinkBinary
. I'm not sure it's warranted in the case of maybeOverwrite
. I'm personally not convinced that the code is made more legible by just doing it for maybeOverwrite
, but I've included it in the latest commit (9f594be) for you to be the judge :)
9f594be
to
b778903
Compare
Is everybody happy with how the feedback was addressed? If so, I'm going to merge (and if nobody answers, I'm merging on Tuesday). |
@Mergifyio rebase |
b778903
to
f27e87a
Compare
✅ Branch has been successfully rebased |
CI is OK. Merging. Thank you everybody! |
Thank you @Mikolaj! |
When linking binaries into a globally accessible location on the machine
--overwrite-policy=always
is needed if an existing file sits where we are trying to create a link. This allows for a prompt-the-user strategy.Please include the following checklist in your PR:
NA: Couldn't find any existing documentation about
overwrite-policy
.[ci skip]
is used to avoid triggering the build bots.How I tested the change:
I simply ran
cabal new-install
oncabal-install
(after having installedcabal-install
with my feature.WIP
--overwrite-policy=prompt
as the default. This was my idea with the patch. I need a bit of help on how to achieve this though as I'm not familiar with the code-base.