Skip to content

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

Merged
merged 1 commit into from
Apr 4, 2019
Merged

mix: follow XDG base dir specification #8933

merged 1 commit into from
Apr 4, 2019

Conversation

maennchen
Copy link
Member

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.

Copy link
Member

@josevalim josevalim left a 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.

* `XDG_DATA_HOME/mix`

"""
def mix_config_homes do
Copy link
Member

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.

_ -> System.put_env("MIX_HOME", mix_home)
end

case xdg_data_home do
Copy link
Member

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.

_ -> System.put_env("XDG_DATA_HOME", xdg_data_home)
end

case xdg_config_home do
Copy link
Member

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.

# Reset Env Variables
on_exit(fn ->
case mix_home do
nil -> System.delete_env("MIX_HOME")
Copy link
Member

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.

@maennchen
Copy link
Member Author

@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 on_exit as is?

@josevalim
Copy link
Member

josevalim commented Apr 4, 2019 via email

@maennchen
Copy link
Member Author

@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")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{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")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{nil, directory} when is_binary(directory) -> :filename.basedir(:user_config, "mix")
{nil, directory} when is_binary(directory) -> Path.join(directory, "mix")

@josevalim josevalim merged commit afaf889 into elixir-lang:master Apr 4, 2019
@josevalim
Copy link
Member

❤️ 💚 💙 💛 💜

@maennchen maennchen deleted the xdg branch April 4, 2019 19:35
mobileoverlord added a commit to nerves-project/nerves that referenced this pull request Oct 29, 2019
This also adds support for XDG_DATA_HOME as described in  elixir-lang/elixir#8933
mobileoverlord added a commit to nerves-project/nerves that referenced this pull request Oct 29, 2019
This also adds support for XDG_DATA_HOME as described in  elixir-lang/elixir#8933
mobileoverlord added a commit to nerves-project/nerves that referenced this pull request Nov 18, 2019
This also adds support for XDG_DATA_HOME as described in  elixir-lang/elixir#8933
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants