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
~/.swiftpm config, cache to follow the XDG base dir spec #6204
Comments
Could you clarify what specific OS and if it's Linux, what distributions do you expect this to be applicable on? |
Apple Swift version 5.7.2 macOS 13.1 |
To my understanding this XDG spec is Linux-specific, how is it related to macOS then? |
My main intention is to prevent the creation of symlinks in the home directory, as a macOS user they are pointless to me. What is the purpose of these symlinks? I assumed they are for discoverability and if that is the case I am suggesting a cross-platform solution, my impression is that XDG spec are widely adopted. |
Here's a quick overview of what the XDG structure means: The gist of it is, people (myself) don't want their $HOME directory cluttered with a bunch of useless folders, one of which is
A further example, this is how The request would to have SPM do the same. Firstly, instead of hardcoding the dotfile location, allow the user to control this through some env variable:
This would already please the vast majority of people requesting this feature. Secondly, if you would like to fully comply with the XDG specs, the cache, config, security and cross-compilation directories should be individually configurable, through some ENV variables, example: export SWIFT_PM_CONFIG=$XDG_CONFIG_HOME/swiftpm
export SWIFT_PM_CACHE=$XDG_CACHE_HOME/swiftpm
// Unsure what dotSwiftPMSecurityDirectory and swiftPMCrossCompilationDestinationsDirectory should be.
// Probably DATA? Then, Considering I would be glad to submit a PR, as soon as we can agree on the details. |
@MaxDesiatov Any thoughts on my comment? |
Would you provide some confirmation that macOS or Windows adopt XDG? I'm not sure that's the case, thus I'm not sure how this would be cross-platform. From that perspective, it's also unclear to me why this is filed as a bug report against macOS. |
I don't think or at least I am not aware of an OS adoption of XDG. I meant that users adopting it, please see the more detailed comment from @lordzsolt above. This ticket was intended as a feature request, it is also currently labeled as a feature request (enhancement).
I realize that my response is not correct, I am a macOS user but this request should be for all supported OS. I updated this now. Maybe we shouldn't discuss the XDG topic. The main ask of this ticket is how can we prevent the creation of symlinks in the $HOME directory or how can we configure the location where these symlinks are created. I believe users would like the option to configure the locations with env variables. Please see the example from @lordzsolt. Hope this clarifies the ask. |
@MaxDesiatov Have you had a change to review my comment here? I think it answers your question. |
The XDG Base Dir Spec is not an OS-level spec. It's a spec aimed at solving the problem explained above: "As a user, I don't want my home directory filled with random configuration files for programs I have installed." Instead of having every application author decide on their own storage method, XDG provides a standardized way to organize configs, stored data, and cache data. The TL;DR is:
On my machine,
|
Absolutely.
No. Actually, the symlinks are there because the files themselves formerly (and erroneously) lived there. Since older toolchains looked for them there, mutual compatibility between toolchains required a transition period where the old and new paths were unified by symlinks. Since that transitional code is marked for removal in the version following 5.6, I assume in was simply forgotten and that a PR to clean it out and eliminate the symlinks would very likely be accepted. The transition work started because everyone agrees with you about the files not belonging in Aside from the deprecated symlinks, SwiftPM derives its paths from Foundation, which has respected XDG on relevant platforms since at least 2017. Foundation’s abstractions use XDG on platforms where it makes sense, but not on those where it is at odds with the operating system. On macOS, Foundation adheres to App Store standards. For example, the real cache directory will automatically be cleaned up periodically by the operating system, whereas an arbitrary custom one will not. Foundation roughly cascades by doing what the platform wants (e.g. on macOS) and then for platforms which defer such responsibilities, it asks the user’s preferences through mechanisms like XDG (e.g. on Linux). So if you are using a platform where XDG applies (i.e. one that does not have native instructions for developers to follow), and your environment variables are being ignored, then please report the details in a fresh issue. But the discussion so far seems to only be about macOS, where adoption is unlikely and any attempt to convince otherwise would have to happen over in the Foundation repository anyway. |
I suppose I should clarify: I don't actually care about the XDG spec being followed on macOS. I care about not having this directory in I only found this issue because one day |
Same here |
I personally use Foundation defaults for Native macOS Apps eg ~/Library etc . Anything, command line in Darwin, is usually ported from Linux or BSD I use XDG dirs. Usually applications using XDG have an ordered list of default directories usually something like XDG_CONFIG_HOME/name/config_file then $HOME/.config_file and possibly depending on usage you may have global dirs for user and globals for all users e.g under /etc It also makes sense to be able to override XDG and program defaults with a custom environment variables for individual configurations and custom development environments. or at least change the location of the main config file then to be able to configure other paths within that file. |
Is there an open issue for this cleanup? |
When reading the code comment you linked to, as well as the other The migration code, which should be cleaned up just migrates from:
The code which is outside the |
### 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>
Maybe some documentation somewhere? |
Description
Conform to the XDG Base Directory spec with no symlinks from the "$HOME" directory.
I assume the purpose of these symlinks is discoverability.
An alternative solution would be to provide an option to not create the symlinks in the "$HOME" directory e.g. env variable
Expected behavior
No symlinks "~/.swiftpm" in the home directory
Actual behavior
No response
Steps to reproduce
No response
Swift Package Manager version/commit hash
No response
Swift & OS version (output of
swift --version && uname -a
)macOS
Linux - all distributions
windows
The text was updated successfully, but these errors were encountered: