Skip to content

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

Merged
merged 3 commits into from
Jun 11, 2021
Merged

Conversation

stevapple
Copy link
Contributor

@stevapple stevapple commented May 11, 2021

If linking oldBuildPath fails, SwiftPM will emit a warning instead of an error.

Motivation:

Symlinking oldBuildPath is not a vital step of swift build, but emitting an error will depress the run and test commands. This largely troubled Windows users, since symlinking requires elevated privileges on Windows.

Modifications:

Codes of linking oldBuildPath is now wrapped with do-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.

@tomerd
Copy link
Contributor

tomerd commented May 11, 2021

I think this is good change. @abertelrud @neonichu wdyt?

@tomerd
Copy link
Contributor

tomerd commented May 11, 2021

@swift-ci please smoke test

@stevapple
Copy link
Contributor Author

@abertelrud How do you think of this patch?

@abertelrud
Copy link
Contributor

@stevapple Apologies for my delayed response here. This looks good to me.

@abertelrud abertelrud self-requested a review May 24, 2021 18:45
Co-authored-by: Anders Bertelrud <[email protected]>
Copy link
Contributor

@abertelrud abertelrud left a 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!

@abertelrud
Copy link
Contributor

@swift-ci please smoke test

@abertelrud
Copy link
Contributor

@swift-ci please smoke test linux

try localFileSystem.removeFileTree(oldBuildPath)
do {
if localFileSystem.exists(oldBuildPath) {
try? localFileSystem.removeFileTree(oldBuildPath)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Suggested change
try? localFileSystem.removeFileTree(oldBuildPath)
try localFileSystem.removeFileTree(oldBuildPath)

Copy link
Contributor Author

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🤔

Copy link
Contributor

@tomerd tomerd Jun 3, 2021

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)

@tomerd
Copy link
Contributor

tomerd commented Jun 4, 2021

@swift-ci please smoke test

@abertelrud
Copy link
Contributor

The failure looks unrelated to the change, and looks like the same one I saw in a different PR:

Undefined symbols for architecture x86_64:
  "swift::swift51override_conformsToSwiftProtocol(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::StringRef, swift::TargetProtocolConformanceDescriptor<swift::InProcess> const* (*)(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::StringRef))", referenced from:
      _Swift50Overrides in libswiftCompatibility50.a(Overrides.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Rerunning just for macOS to see if it was a one-off.

@abertelrud
Copy link
Contributor

@swift-ci please smoke test macos

@abertelrud
Copy link
Contributor

@tomerd All ok to merge this?

@tomerd tomerd merged commit 05c313e into swiftlang:main Jun 11, 2021
stevapple added a commit to stevapple/swift-package-manager that referenced this pull request Jun 16, 2021
stevapple added a commit to stevapple/swift-package-manager that referenced this pull request Jun 16, 2021
tomerd pushed a commit that referenced this pull request Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants