Skip to content

Allow scratchPath to be a relative path #1824

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

Conversation

kateinoigakukun
Copy link
Member

@kateinoigakukun kateinoigakukun commented Nov 15, 2024

Interpret it as relative to the project root directory if it's a relative path.

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should swiftSDKsDirectory also be interpreted relative to the project root? And could you add that the paths are relative to the project root to Configuration File.md?

Comment on lines 306 to 308
explicitDirectory: options.swiftPMOrDefault.swiftSDKsDirectory.map {
try AbsolutePath(validating: $0, relativeTo: AbsolutePath(projectRoot))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to have a SwiftSDK installed relative to your project? Don’t you typically install Swift SDKs globally?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it would be typically an absolute path. But I think it's not harmful to interpret it as relative to project root only when it's a relative path. Note that AbsolutePath(validating: relativeTo:) uses the first argument as is if it's absolute.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing I’m wondering is whether interpreting the path relative to the project root is the right way to go. You could have a global SourceKit-LSP configuration file at ~/.sourcekit-lsp/config.json and it wouldn’t be unreasonable to expect that the Swift SDK path is interpreted relative to that configuration file. If we don’t allow relative paths, we don’t need to worry about any ambiguity here.

I think for the scratch directory it’s natural to assume that it’s relative to the project root because having a global scratch directory for all project makes very little sense, so making that path relative to the project root makes perfect sense, I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, that makes sense. Thank you for your explanation, I reverted swiftSDKsDirectory change.

@kateinoigakukun kateinoigakukun force-pushed the katei/interpret-relative-scratch-dir branch from 8edd50c to 70618ca Compare November 16, 2024 22:02
@kateinoigakukun kateinoigakukun changed the title Allow scratchPath and swiftSDKsDirectory to be relative paths Allow scratchPath to be relative path Nov 16, 2024
@kateinoigakukun kateinoigakukun changed the title Allow scratchPath to be relative path Allow scratchPath to be a relative path Nov 16, 2024
Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Yuta!

@ahoppen
Copy link
Member

ahoppen commented Nov 18, 2024

@swift-ci Please test

Interpret it as relative to the project root directory if it's a
relative path.
@kateinoigakukun kateinoigakukun force-pushed the katei/interpret-relative-scratch-dir branch from 70618ca to 184fa12 Compare November 19, 2024 02:20
@kateinoigakukun
Copy link
Member Author

@swift-ci Please test

@ahoppen
Copy link
Member

ahoppen commented Nov 19, 2024

@swift-ci Please test Windows

@ahoppen ahoppen merged commit 8d13afa into swiftlang:main Nov 19, 2024
3 checks passed
ahoppen added a commit to ahoppen/sourcekit-lsp that referenced this pull request Nov 19, 2024
@ahoppen ahoppen mentioned this pull request Nov 19, 2024
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.

2 participants