For those who move ~/.ghcup out of their home directories, having .ghcup be a hidden directory is pointless (eg I have GHCUP_INSTALL_BASE_PREFIX=~/.local/opt).
It would be preferable to just be able to set GHCUP_HOME=~/.local/opt/ghcup.
A more ambitious version of this would be to XDGify ghcup, but that's much more effort than this itch warrants.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related or that one is blocking others.
Learn more.
I think that's problematic and counter-intuitive... e.g. if someone moves the .ghcup folder from $HOME location somewhere else... it suddenly doesn't work anymore. I think a static subfolder name is important.
That might be true for XDG support (there are only two options). Arbitrary relocatable directory is something different. Yes, there could be a runtime check:
if [ $GHCUP_INSTALL_BASE_PREFIX = $HOME ] ; then use .ghcupelse use ghcupfi
However, I'm still not sure that's intuitive. It will also be backwards-incompatible and may break existing installations. Now you need to support both formats for compatibility and pick an arbitrary one if both exist...
Which is why I suggested the GHCUP_HOME method to begin with.
By changing the name, gives a clean break
Has clear semantics
Supports old workflows
As to the point that a wrong setting can smash $HOME, the same could be said for pointing the data directories of any other program at $HOME. As long as the default is safe and the semantics are clear, I suspect this bug will never be triggered.
Alternatively, we could go the XDG route and use the logic
if [ -d "$XDG_DATA_HOME/ghcup" ] ; then GHCUP_HOME="$XDG_DATA_HOME/ghcup"else GHCUP_HOME=~/.ghcupfi
or something similar. We'd need to figure out the correct XDG semantics, but this has all of the benefits of the above, a savings of one envvar, and the idiotproofing of working within a subdirectory.
Which is why I suggested the GHCUP_HOME method to begin with.
Now both variables are set, what's the semantics?
As to the point that a wrong setting can smash $HOME, the same could be said for pointing the data directories of any other program at $HOME
I cannot follow this reasoning. As you can see with the link you just gave wrt XDG... the user does not have the control to choose the directory, only the base of it via XDG_ variables.
Not every ghcup user is a power user and I've seen people do weird things in the past. Until now, ghcup has not wiped anyone's home directory and I want to keep it that way.
Being xdg compliant is an idea. That can be done backwards-compatible like any other app. But it is still disruptive, because simple instructions like rm -rf ~/.ghcup don't work anymore, if the new location by default is XDG. I'm dealing with a lot of users that are novice on the command line and need help with understanding what the PATH variable is (which will now also need to account for multiple possible locations). If ghcup location depends on ghcup version, environment variables and runtime semantics, then it will most certainly increase my support burden.
What I could think of is a global switch that triggers xdg behavior. Then you could add to your bashrc/whatnot alias ghcup='ghcup --xdg' and it would use xdg directories only (and still not allow to choose the final directory component).
Hrm. You're referring to the potential that a user has both the old and the new environment variable lying around? My intuition would be that the newest way of referring to the data directory would take precedence.
I cannot follow this reasoning. As you can see with the link you just gave wrt XDG... the user does not have the control to choose the directory, only the base of it via XDG_ variables.
Fair if we're considering XDG support. However, programs have permitted setting the data directory directly, e.g. STACK_ROOT. Considering the user base, as you've pointed out, that would be a dangerous path to go down, though.
To recap, we have the following options:
method
logic
no bad configs
can be made visible
backwards-compatible
consistent with world
GHCUP_INSTALL_BASE_PREFIX (current)
${var:-$HOME}/.ghcup
yes (subdirectory)
no (subdir=.ghcup)
yes
no (cf STACK_ROOT)
GHCUP_HOME
${var:-$HOME/.ghcup}
no (GHCUP_HOME=HOME)
yes
yes (fallback)
yes (cf STACK_ROOT)
autohide (current w/ hiding logic)
$HOME/.ghcup:$var/ghcup
yes (subdirectory)
yes (move out)
no (when customized)
no, but emulates world behaviour. counterintuitive, though
Sure. The standard gives us a nice way of making this arbitrary choice that follows the general current Linux trend, but as pointed out we will need a little more to buy backwards compatibility.
The usage message doesn't mention the xdg option, but apart from that a quick strace suggests all's well. My build environment doesn't complain either.
A little annoying to have yet another envvar to carry around, but it is the best I could expect under the circumstances.
Checked behaviour with and without `GHCUP_USE_XDG_DIRS, lgtm. However, still missing mention of that var in usage message. But that's my only problem with the patch.