-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Change symlink error to warning #3490
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
Conversation
I think this is good change. @abertelrud @neonichu wdyt? |
@swift-ci please smoke test |
@abertelrud How do you think of this patch? |
@stevapple Apologies for my delayed response here. This looks good to me. |
Co-authored-by: Anders Bertelrud <[email protected]>
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.
Looks great to me. Thanks!
@swift-ci please smoke test |
@swift-ci please smoke test linux |
Sources/Build/BuildOperation.swift
Outdated
try localFileSystem.removeFileTree(oldBuildPath) | ||
do { | ||
if localFileSystem.exists(oldBuildPath) { | ||
try? localFileSystem.removeFileTree(oldBuildPath) |
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.
with this change any error in attempting to delete the oldBuildPath is ignored. intentional?
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.
Yes. In most cases deletion error will also lead to symlink error (if not, there is actually nothing wrong), so I ignored it here.
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.
Since this is already in a do
catch
block, we should not need to ignore the error.
try? localFileSystem.removeFileTree(oldBuildPath) | |
try localFileSystem.removeFileTree(oldBuildPath) |
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.
This may lead to confusion because the warning here indicates an error in symlinking instead of deleting.
If we want to handle it, there should be another nested do-catch
, which I don’t think necessary🤔
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.
we can change the warning to say unable to delete \(oldBuildPath) or create symbolic link at \(oldBuildPath): \(error)
@swift-ci please smoke test |
The failure looks unrelated to the change, and looks like the same one I saw in a different PR:
Rerunning just for macOS to see if it was a one-off. |
@swift-ci please smoke test macos |
@tomerd All ok to merge this? |
Cherrypicked from swiftlang#3490
Cherrypicked from swiftlang#3490
If linking
oldBuildPath
fails, SwiftPM will emit a warning instead of an error.Motivation:
Symlinking
oldBuildPath
is not a vital step ofswift build
, but emitting an error will depress therun
andtest
commands. This largely troubled Windows users, since symlinking requires elevated privileges on Windows.Modifications:
Codes of linking
oldBuildPath
is now wrapped withdo-catch
to capture the error and change it into a warning.Result:
If linking
oldBuildPath
fails, SwiftPM will emit a warning instead of an error.