hexpm / hex

Package manager for the Erlang ecosystem.
https://hex.pm
971 stars 185 forks source link

mix hex.config is incorrect when using MIX_XDG #850

Closed supersimple closed 3 years ago

supersimple commented 3 years ago

Screenshot from 2021-01-13 08-00-18

the home config says "(default)" but it is derived from the MIX_XDG flag being set. perhaps it should say "XDG_DATA_HOME"? Otherwise, just some way to indicate it was derived because the MIX_XDG flag was set.

wojtekmach commented 3 years ago

are you running on old Hex? :) for me on master it doesn't show home config anymore, instead there's cache_home, config_home, and data_home. You're right however that these shouldn't show up as (default) but we should indicate that MIX_XDG is being used. And if e.g. XDG_CONFIG_HOME is set, we should show that instead.

ericmj commented 3 years ago

How should we display it? I could see that the following may be confusing since MIX_XDG does not set the value it only changes what we use as default value.

config_home: "/home/ericmj/.config/hex (using MIX_XDG)

supersimple commented 3 years ago

@wojtekmach i have 0.20.6 on that version of elixir. in my mental model, the value comes from XDG_CONFIG_HOME so that is what I would expect. But I do understand it is weird that you could have that var set, but not MIX_XDG and it would be ignored.

wojtekmach commented 3 years ago

config_home: "/home/ericmj/.config/hex (using MIX_XDG)

I think this is a little bit confusing but I can't come up with anything better so I think we should proceed with it unless there are other ideas. We do document MIX_XDG in mix help hex.config so I think that's pretty clear. Also the behaviour is opt-in so perhaps it's less confusing since the user had to explicitly enable it.

We actually have two scenarios:

$ MIX_XDG=true mix hex.config | grep config_home
config_home: "/home/ericmj/.config/hex (using MIX_XDG)

# option 1
$ MIX_XDG=true XDG_CONFIG_HOME=/config mix hex.config | grep config_home
config_home: "/config/hex (using MIX_XDG)

should the second one by that or:

# option 2
config_home: "/config/hex (using XDG_CONFIG_HOME)

or:

# option 3
config_home: "/config/hex (using MIX_XDG and XDG_CONFIG_HOME)

?

I think option 1 is fine since again the behaviour is opt-in.

supersimple commented 3 years ago

yeah, I like option 1 the best. At the end of the day, we have a limited amount of space to work with. Hopefully, if you have configured MIX_XDG you had some idea of what the effect would be.

supersimple commented 3 years ago

@ericmj if that is okay with you, I have some OSS time scheduled at work today and I'll put up a PR with option 1

ericmj commented 3 years ago

@supersimple Sounds good.