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

2.5k views Asked by At

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?

2

There are 2 answers

1
sierra-alpha On BEST ANSWER

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.

2
miyalys On

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.