-
Notifications
You must be signed in to change notification settings - Fork 1.4k
improve location of config directory #3430
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
motivation: use more idiomatic location for SwiftPM config changes: * on darwin platforms, use ~/Library/org.swift.swiftpm to store SwiftPM configs, which is more idiomatic * if idiomatic config directory is different from ~/.swift/config, create a symlink ~/.swift/config -> idiomatic * add temporary transition code for beta users of 5.5 that may already have ~/.swift/config in place * refactor and centralize the computation of config directory * refactor and centralize the computation of cache directory (no functional changes)
|
@neonichu @yim-lee @abertelrud looking for early feedback on the approach here. as we are going to need to lean on the config directory more heavily soon (SE-0292, others) this is an attempt to make accessing it safer and more robust, along the lines of how we deal with the caches directory. one thing to note is that unlike caches directory which has clear idiomatic location lookup via I chose to use |
|
If we're still creating I don't have strong opinions but would be inclined to suggest keeping these files where they are. |
yim-lee
left a comment
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 reasonable I think. It would help if we can include the actual paths in the comments to make the code more readable.
| extension FileSystem { | ||
| private var idiomaticUserCacheDirectory: AbsolutePath? { | ||
| // in TSC: FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask) | ||
| self.cachesDirectory |
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.
Is this ever nil?
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, it could be if there is no idiomatic location, iow the Foundation API above can return nil
|
I like storing the configuration in |
I thought that if it's going to be under Not super-clear what the distinction is between "Support files for the app" and "Other app data files" |
|
@swift-ci please smoke test |
|
@abertelrud @neonichu looks like there is a consensus on |
|
looks like driver is failing the PR @artemcm ? |
|
Random fly-by comment that this looks nice 👍 😄 |
|
@swift-ci please smoke test macOS |
motivation: use more idiomatic location for SwiftPM config changes: * on darwin platforms, use ~/Library/org.swift.swiftpm to store SwiftPM configs, which is more idiomatic * if idiomatic config directory is different from ~/.swift/config, create a symlink ~/.swift/config -> idiomatic * add temporary transition code for beta users of 5.5 that may already have ~/.swift/config in place * refactor and centralize the computation of config directory * refactor and centralize the computation of cache directory (no functional changes)
motivation: use more idiomatic location for SwiftPM config changes: * on darwin platforms, use ~/Library/org.swift.swiftpm to store SwiftPM configs, which is more idiomatic * if idiomatic config directory is different from ~/.swift/config, create a symlink ~/.swift/config -> idiomatic * add temporary transition code for beta users of 5.5 that may already have ~/.swift/config in place * refactor and centralize the computation of config directory * refactor and centralize the computation of cache directory (no functional changes)
|
Sorry, haven't looked at GitHub in a bit, but I would still say it would be much preferable to conform to the XDG Base Directory spec on Linux, with no symlink from the home directory if it can be at all avoided. There's a bunch of advantages, I'll just mention the ones I personally find most important:
Debian, and by extension Ubuntu, "strongly encourages" adoption, there is a feature page for Fedora (which admittedly hasn't been touched in a while), and the Arch Linux Wiki has a rather extensive entry, so it seems like there is at least some consensus among distributions as well. For reference, there are also some rather recent changes and some very recent discussion about providing a specified directory for user-installed binaries as well, which could be applicable to SPM in the future. This of course is no show-stopper either way, but I think the advantages are quite nice. And I also think every small bit that makes Swift feel more at home on Linux will help in working against the perception of Swift being "just that Apple language". |
What's the specific issue with providing the symlink? Seems to me that it would be additive to adhering to Linux conventions and could help users of other platforms to find the files in question. |
It would still clutter the home directory. Additionally the symlink would either be wrong, or need to be continually recreated/updated when the directory is customized via env variables, which would be especially confusing if one were to run multiple SwiftPM instances simultaneously, with different configuration directories (e.g. in a CI system). I also think having two paths to the config would lead to more confusion than it would help: Do things break if I remove the symlink? What if i turn the symlink into a directory, which one wins? Why does one blog post mention And if other platforms also use idiomatic directories, users wouldn't be looking for |
|
Thanks for elaborating on this.
This does indeed seem to be a significant issue. |
It seems that the discussion about this has fizzled out. Sadly, Would it be welcome to open a new issue about supporting |
|
@lgarron Yah, please open an issue. |
### Motivation: As discussed in #6204, users would like to have a clean home directory. And in the discussions following the merge of #3430, it seems there is a willingness to adhere to the XDG spec, and support `~/.config/swiftpm`. ### Modifications: If the `XDG_CONFIG_HOME` environmental variable is defined, use `$XDG_CONFIG_HOME/swiftpm` as the root `dotSwiftPM` directory. ### Result: The symlinks that were previously stored in `~/.swiftpm` are now stored in `$XDG_CONFIG_HOME/swiftpm` when this variable is defined, therefore not cluttering the home directory of users. Closes #6204 --------- Co-authored-by: Max Desiatov <m_desiatov@apple.com>
### Motivation: As discussed in swiftlang#6204, users would like to have a clean home directory. And in the discussions following the merge of swiftlang#3430, it seems there is a willingness to adhere to the XDG spec, and support `~/.config/swiftpm`. ### Modifications: If the `XDG_CONFIG_HOME` environmental variable is defined, use `$XDG_CONFIG_HOME/swiftpm` as the root `dotSwiftPM` directory. ### Result: The symlinks that were previously stored in `~/.swiftpm` are now stored in `$XDG_CONFIG_HOME/swiftpm` when this variable is defined, therefore not cluttering the home directory of users. Closes swiftlang#6204 --------- Co-authored-by: Max Desiatov <m_desiatov@apple.com>
### Motivation: As discussed in swiftlang#6204, users would like to have a clean home directory. And in the discussions following the merge of swiftlang#3430, it seems there is a willingness to adhere to the XDG spec, and support `~/.config/swiftpm`. ### Modifications: If the `XDG_CONFIG_HOME` environmental variable is defined, use `$XDG_CONFIG_HOME/swiftpm` as the root `dotSwiftPM` directory. ### Result: The symlinks that were previously stored in `~/.swiftpm` are now stored in `$XDG_CONFIG_HOME/swiftpm` when this variable is defined, therefore not cluttering the home directory of users. Closes swiftlang#6204 --------- Co-authored-by: Max Desiatov <m_desiatov@apple.com>
motivation: use more idiomatic location for SwiftPM config
changes: