Skip to content
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

Stow should look in $STOW_DIR for .stowrc #121

Open
andrewbraxton opened this issue Jan 18, 2025 · 1 comment
Open

Stow should look in $STOW_DIR for .stowrc #121

andrewbraxton opened this issue Jan 18, 2025 · 1 comment

Comments

@andrewbraxton
Copy link

I was a bit surprised to realize that running stow from somewhere outside of my $STOW_DIR did not respect the .stowrc in $STOW_DIR. The documentation does indicate that this is expected behavior:

Stow searches for default command line options at .stowrc (current directory) and ~/.stowrc (home directory) in that order.

I feel that $STOW_DIR should be added to this list, since my understanding the point of $STOW_DIR is to let you run stow from outside of your $STOW_DIR. Of course, you can use the ~/.stowrc location (which I will start doing), but IMO the natural place to place your .stowrc is in your $STOW_DIR since it's likely version-controlled.

(Bonus suggestion: Look in ${XDG_CONFIG_HOME:-$HOME} instead of $HOME for .stowrc)

@aspiers
Copy link
Owner

aspiers commented Jan 19, 2025

This sounds like a reasonable enhancement. There is one caveat in implementing this however: $STOW_DIR/.stowrc cannot be allowed to contain the -d / --dir options. There are two reasons for this:

  1. Stow has no way to find the Stow directory unless it's told where it is, short of scanning the entire filesystem. So $STOW_DIR/.stowrc cannot be relied on for locating the Stow directory. (And BTW there can be multiple Stow directories on a system.)
  2. It wouldn't make sense for $STOW_DIR/.stowrc to contain --dir /path/to/a/different/stow/dir as that would lead to very surprising behaviour.

With that caveat in mind, I'd definitely welcome a PR for this. The changes to get_config_file_options in stow.in should be extremely simple. The only slightly tricky thing would be adding relevant tests to t/rc_options.t.

Regarding the bonus suggestion, making Stow also check $XDG_CONFIG_HOME if defined sounds like a good idea. Although in that case it should still fall back to checking $HOME, otherwise if $XDG_CONFIG_HOME is defined but .stowrc is in $HOME, it will get ignored. A PR for this would be very welcome and even easier to make than a PR for above (perhaps both could be done at the same time, in fact).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants