-
Notifications
You must be signed in to change notification settings - Fork 3.5k
mix: follow XDG base dir specification #8933
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
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.
Thank you for the PR ❤️ I have added some comments.
lib/mix/lib/mix/utils.ex
Outdated
* `XDG_DATA_HOME/mix` | ||
|
||
""" | ||
def mix_config_homes do |
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.
I think this can be the same as mix_home
, i.e. we will just lookup at one of the directories, depending the variable is set. In fact, this change is even backwards incompatible as it can load multiple configs thaat wouldn't be loaded today.
lib/mix/test/mix/utils_test.exs
Outdated
_ -> System.put_env("MIX_HOME", mix_home) | ||
end | ||
|
||
case xdg_data_home do |
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.
No need to revert this, we know from the test_helper they should be nil.
lib/mix/test/mix/utils_test.exs
Outdated
_ -> System.put_env("XDG_DATA_HOME", xdg_data_home) | ||
end | ||
|
||
case xdg_config_home do |
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.
No need to revert this, we know from the test_helper they should be nil.
lib/mix/test/mix/utils_test.exs
Outdated
# Reset Env Variables | ||
on_exit(fn -> | ||
case mix_home do | ||
nil -> System.delete_env("MIX_HOME") |
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.
It should never be nil from the test helper.
@josevalim I did some fixes. Is the general idea that a test cleans up the env variables it set itself or should I leave the |
If used once, I do in the same test. Otherwise I move to on_exit on setup.
--
*José Valimwww.plataformatec.com.br
<http://www.plataformatec.com.br/>Founder and Director of R&D*
|
@josevalim Ok, then I think all comments are adressed :) |
System.get_env("MIX_HOME") || Path.expand("~/.mix") | ||
case {System.get_env("MIX_HOME"), System.get_env("XDG_DATA_HOME")} do | ||
{directory, _} when is_binary(directory) -> directory | ||
{nil, directory} when is_binary(directory) -> :filename.basedir(:user_data, "mix") |
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.
{nil, directory} when is_binary(directory) -> :filename.basedir(:user_data, "mix") | |
{nil, directory} when is_binary(directory) -> Path.join(directory, "mix") |
def mix_config_home do | ||
case {System.get_env("MIX_HOME"), System.get_env("XDG_CONFIG_HOME")} do | ||
{directory, _} when is_binary(directory) -> directory | ||
{nil, directory} when is_binary(directory) -> :filename.basedir(:user_config, "mix") |
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.
{nil, directory} when is_binary(directory) -> :filename.basedir(:user_config, "mix") | |
{nil, directory} when is_binary(directory) -> Path.join(directory, "mix") |
❤️ 💚 💙 💛 💜 |
This also adds support for XDG_DATA_HOME as described in elixir-lang/elixir#8933
This also adds support for XDG_DATA_HOME as described in elixir-lang/elixir#8933
This also adds support for XDG_DATA_HOME as described in elixir-lang/elixir#8933
Implementation of #8818
The documentation is not as good as I'd expect. Since I'm not a native speaker some help would be appreciated.