0

I am having problem in using stow correctly. The scrip I use to install all my stow's is :

cd ~/Utility/configs
for file in *; do
  # Only run Stow on the directories in the dotfiles folder and not the individual files.
  # Using 'basename' strips the filepath from the directory name. 
  if [ -d ${file} ]; then
    stow  $(basename $file) -t ~/
    echo "$(basename $file) stowed."; 
  fi
done

Now, I have, in vim directory as: ~Utility/configs/vim/ with:

tree . -a  -L 2
.
├── .stow-local-ignore
├── .vim
│   ├── autoload
│   ├── plugged
│   └── UltiSnips
└── .vimrc

Among them, I want to ignore plugged not to be stowed and hence the .stow-local-ignore:

\.vim/plugged
\.vim/spell

But this is not doing what is intended and plugged is always stowed. Basically, whatever is inside ~/.vim/ is inside ~/Utility/configs/vim/.vim. This I don't want. I specifically just want only autoload and Ultisnips to be stowed, nothing else.

How I can do that?

NB: I have taken vim as an example, but this is not related to vim, but to stow. So I have posted here, and not in vim channel.

stow output with verbose=5

Stowing contents of Utility/configs/vim (cwd=/home/rudra)
  => Utility/configs/vim
  is_a_node(.)
  link_task_action(.): no task
  dir_task_action(.): no task
    parent_link_scheduled_for_removal(.): prefix 
    parent_link_scheduled_for_removal(.): returning false
  is_a_node(.): really exists
  Using ignore file: Utility/configs/vim/.stow-local-ignore
    Ignore list regexp for paths:    /(?^:(^|/)(\.vim/spell|^/\.stow\-local\-ignore$|\.vim/plugged)(/|$))/
    Ignore list regexp for segments: none
  Not ignoring .vimrc
Stowing Utility/configs / vim / .vimrc
  => Utility/configs/vim/.vimrc
  is_a_link(.vimrc)
  link_task_action(.vimrc): no task
  is_a_link(.vimrc): returning 0
  is_a_node(.vimrc)
  link_task_action(.vimrc): no task
  dir_task_action(.vimrc): no task
    parent_link_scheduled_for_removal(.vimrc): prefix .vimrc
    parent_link_scheduled_for_removal(.vimrc): returning false
  is_a_node(.vimrc): returning false
LINK: .vimrc => Utility/configs/vim/.vimrc
  Using ignore file: Utility/configs/vim/.stow-local-ignore
    Using memoized regexps from Utility/configs/vim/.stow-local-ignore
    Ignore list regexp for paths:    /(?^:(^|/)(\.vim/spell|^/\.stow\-local\-ignore$|\.vim/plugged)(/|$))/
    Ignore list regexp for segments: none
  Ignoring path /.stow-local-ignore
  Using ignore file: Utility/configs/vim/.stow-local-ignore
    Using memoized regexps from Utility/configs/vim/.stow-local-ignore
    Ignore list regexp for paths:    /(?^:(^|/)(\.vim/spell|^/\.stow\-local\-ignore$|\.vim/plugged)(/|$))/
    Ignore list regexp for segments: none
  Not ignoring .vim
Stowing Utility/configs / vim / .vim
  => Utility/configs/vim/.vim
  is_a_link(.vim)
  link_task_action(.vim): no task
  is_a_link(.vim): returning 0
  is_a_node(.vim)
  link_task_action(.vim): no task
  dir_task_action(.vim): no task
    parent_link_scheduled_for_removal(.vim): prefix .vim
    parent_link_scheduled_for_removal(.vim): returning false
  is_a_node(.vim): returning false
LINK: .vim => Utility/configs/vim/.vim
Planning stow of package vim... done

@Kusalananda: This is what I am doing, with verbose=2:

pwd
/home/rudra/Utility/configs
 mv vim/.stow-local-ignore ~/
stow -D vim --verbose=2
stow dir is /home/rudra/Utility/configs
stow dir path relative to target /home/rudra/Utility is configs
Planning unstow of package vim...
CONFLICT when unstowing vim: existing target is neither a link nor a directory: .vimrc
.vim did not exist to be unstowed
Planning unstow of package vim... done
WARNING! unstowing vim would cause conflicts:
  * existing target is neither a link nor a directory: .vimrc
All operations aborted.

cd vim/
stow -D .vim --verbose=2
stow dir is /home/rudra/Utility/configs/vim
stow dir path relative to target /home/rudra/Utility/configs is vim
Planning unstow of package .vim...
UltiSnips did not exist to be unstowed
autoload did not exist to be unstowed
plugged did not exist to be unstowed
Planning unstow of package .vim... done
Processing tasks...

stow -D .vimrc --verbose=2
stow dir is /home/rudra/Utility/configs/vim
stow dir path relative to target /home/rudra/Utility/configs is vim
stow: ERROR: The stow directory vim does not contain package .vimrc
cd ..
ll ~/.vim*
lrwxrwxrwx. 1 rudra rudra  24 Apr 30 16:16 /home/rudra/.vim -> Utility/configs/vim/.vim
-rw-------. 1 rudra rudra 13K Apr 30 16:17 /home/rudra/.viminfo
lrwxrwxrwx. 1 rudra rudra  26 Apr 30 16:10 /home/rudra/.vimrc -> Utility/configs/vim/.vimrc
unlink ~/.vim
unlink ~/.vimrc
cp ~/.stow-local-ignore vim/
stow vim -t ~/ --verbose=2
stow dir is /home/rudra/Utility/configs
stow dir path relative to target /home/rudra is Utility/configs
Planning stow of package vim...
LINK: .vimrc => Utility/configs/vim/.vimrc
LINK: .vim => Utility/configs/vim/.vim
Planning stow of package vim... done
Processing tasks...
Processing tasks... done
tree ~/.vim -L 1
/home/rudra/.vim
├── autoload
├── plugged
└── UltiSnips
5
  • Is the ignore file using regexes or globs? Try without the backslash in front of . – muru Apr 29 '20 at 5:09
  • I tried without any luck, which is probably expected as in the manual: gnu.org/software/stow/manual/… – BaRud Apr 29 '20 at 5:30
  • Did you add the .stow-local-ignore file after stowing your Vim configuration? By stowing the configs, adding the ignore file, and re-stowing/un-stowing, the files ignored in the ignore file would not be touched at all, remaining installed. – Kusalananda Apr 29 '20 at 6:15
  • after adding the ignore file, I unlinked .vim. and restowed – BaRud Apr 29 '20 at 7:38
  • 1
    @BaRud Then the ignore file will have been in effect when you restowed, which means that the links to the already stowed files would not have been removed. – Kusalananda Apr 30 '20 at 8:34
1

The syntax of your ignore file is correct.

The .stow-local-ignore file comes in effect as soon as it is created.

When it is in effect, it affects both stowing, restowing, and unstowing.

This means that if you had stowed a directory, and then added the ignore file, restowing or unstowing that directory would not have affected the already stowed files that are ignored in .stow-local-ignore. The symbolic links that point to them would be left installed.

Therefore, follow this workflow when adding a .stow-local-ignore to a directory:

  1. Make sure that the directory is not stowed.
  2. Add the .stow-local-ignore file.
  3. Stow the directory.

What you should do now is to remove/rename your ignore file, unstow the directory, add the ignore file, and then stow the directory again.

1
  • 1
    I have updated my steps, as per your advice. Can you please check? Its not working yet – BaRud Apr 30 '20 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.