Why doesn't GNU Stow ignore single files in main directory?
Asked Answered
F

2

6

I've added a README to my dotfile folder and since I'm managing each package with stow I'd like to ignore that. From documentation I've read that by default stow uses a preset list which includes README files. Now, this doesn't seem to work. I've also tried adding a .stow-global-ignore but same error. Even forcing with stow -nv --ignore='README.md' * leads to nothing.

$ tree
.
├── i3
├── i3status
├── nvim
├── README.md
├── rofi
├── stow
├── urxvt
└── zsh

$ stow -nv *
LINK: .config/i3/config => ../../.dotfiles/i3/.config/i3/config
LINK: .config/i3status/config => ../../.dotfiles/i3status/.config/i3status/config
LINK: .config/nvim/init.vim => ../../.dotfiles/nvim/.config/nvim/init.vim
stow: ERROR: The stow directory .dotfiles does not contain package README.md

My guess is that ignore list applies only to packages (hence dirs) inside the stow directory? Any workaround for this?

Forceps answered 6/10, 2020 at 18:19 Comment(0)
M
9

I just came across the same issue, I found adding the trailing slash to the wildcard */ meant the glob would only look for directories, ignoring all files at the 'root' (dotfiles folder in my case) of the stow. This ignores my files like the readme.md and license.txt which is what I want.

My stow command becomes (run from within my dotfiles repo directory)

stow -t ~ */

I don't think it's ever valid for stow to try and stow files at the root, I think they need to be always nested in a folder, so potentially this should be the default, but I'm a little vague there. This solution would not work if there was ever a use case for stowing a file from the stow root.

Credit to this post which got me thinking.

Metamorphic answered 31/10, 2020 at 9:8 Comment(1)
Sup to this! It was that simple in the end. Thanks.Forceps
P
2

Write a shell script like

#! /usr/bin/env sh
stow -nv i3 i3status nvim rofi stow urxvt zsh

rather than doing

stow -nv *

?

The issue, I think, is that the * in stow * matches all files including README.md?

Alternately if preferring deny-listing I guess you could use the exclude features of fd or find and pass that to stow with --exec.

Something like:

fd --exclude README.md -d 1 --exec stow -nv

...-d 1 being there to only include immediate subdirectories.

Photocompose answered 10/10, 2020 at 15:39 Comment(2)
I was already thinking about the shell script option but I was hoping I could find some better solutions. I'll give you the correct answer just because it's been 5 days and doesn't seem it will be a hot topic to discuss about. Thanks and cheers.Forceps
I agree. I was having the same issue as you and it's at least the best I've come up with. Would be convenient if it was possible to, say, ignore all files not inside a package, via stow directly. I guess a third option would be putting these "meta files" like README inside a "meta" package and then make stow ignore that but I think I prefer the others personally.Photocompose

© 2022 - 2024 — McMap. All rights reserved.