stow icon indicating copy to clipboard operation
stow copied to clipboard

Dotfiles option doesn't work with directories

Open lhindir opened this issue 5 years ago • 46 comments

Paging @jvkersch in case he has any insight.

I use stow to manage my dotfiles. If I am trying to stow my config for zathura, I run stow --dotfiles zathura from ~/dotfiles, which contains zathura/dot-config/zathura/zathurarc. This outputs:

stow: ERROR: stow_contents() called with non-directory path: dotfiles/zathura/.config

I have no problem if I change the path to zathura/.config. Furthermore, stow --dotfiles bash works fine on the file bash/dot-bashrc. It only fails with directories.

I'll freely admit I know little of the internals here, so I'm sorry if I'm just misunderstanding how to use it. But the error message makes it seem like stow is converting the path before getting the path contents and stowing, when it should be getting the path contents, then converting the path, and finally stowing.

Thanks for any insight you can provide.

lhindir avatar Apr 09 '19 00:04 lhindir

Thanks for the report! I didn't implement --dotfiles, so would welcome some help triaging this one.

aspiers avatar Jun 28 '19 15:06 aspiers

I got bitten by this one too when trying the new release 2.3.0, following is more verbose log when the issue is triggered. Hopefully my comment isn't just seen as a noisy +1 and can help in debugging...

$ stow --ignore='^setup.sh' --ignore='^README.*' --ignore='^@.*'--ignore='^_.*' --target="$HOME" --no-folding --dotfiles alacritty --verbose=5
stow dir is /home/bricewge/project/dotfiles
stow dir path relative to target /home/bricewge is project/dotfiles
cwd now /home/bricewge
cwd restored to /home/bricewge/project/dotfiles
cwd now /home/bricewge
Planning stow of package alacritty...
. not protected
Stowing contents of project/dotfiles/alacritty (cwd=/home/bricewge)
  => project/dotfiles/alacritty
  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
  Ignoring path _alacritty.terminfo due to --ignore=(?^:^_.*\z)
  Ignoring path setup.sh due to --ignore=(?^:^setup.sh\z)
  project/dotfiles/alacritty/.stow-local-ignore didn't exist
  /home/bricewge/.stow-global-ignore didn't exist
  Using built-in ignore list
    Ignore list regexp for paths:    /(?^:(^|/)(^/COPYING|^/LICENSE.*|^/README.*|^/\.stow\-local\-ignore$)(/|$))/
    Ignore list regexp for segments: /(?^:^(\.git|.+~|\.#.+|\.svn|CVS|#.*#|\.gitignore|_darcs|\.hg|\.cvsignore|.+,v|RCS)$)/
  Not ignoring dot-config
  Adjusting: dot-config => .config
Stowing project/dotfiles / alacritty / .config
  => project/dotfiles/alacritty/dot-config
  is_a_link(.config)
  link_task_action(.config): no task
  is_a_link(.config): returning 0
  is_a_node(.config)
  link_task_action(.config): no task
  dir_task_action(.config): no task
    parent_link_scheduled_for_removal(.config): prefix .config
    parent_link_scheduled_for_removal(.config): returning false
  is_a_node(.config): really exists
  Evaluate existing node: .config
  is_a_dir(.config)
  dir_task_action(.config): no task
    parent_link_scheduled_for_removal(.config): prefix .config
    parent_link_scheduled_for_removal(.config): returning false
  is_a_dir(.config): real dir
.config not protected
Stowing contents of project/dotfiles/alacritty/.config (cwd=/home/bricewge)
  => ../project/dotfiles/alacritty/dot-config
stow: ERROR: stow_contents() called with non-directory path: project/dotfiles/alacritty/.config

bricewge avatar Jun 29 '19 12:06 bricewge

Definitely not noise, thanks a lot @bricewge for the extra debug! Unfortunately I'm now packing for a 2 week holiday so am unlikely to have time to look at this soon, but if anyone else can make headway in my absence that would be awesome :)

aspiers avatar Jun 29 '19 13:06 aspiers

Apologies for not replying to the earlier report. I will try to reproduce and I'll see if I can make any headway before @aspiers returns from vacation.

jvkersch avatar Jun 30 '19 17:06 jvkersch

I was able to reproduce, thanks all for the detailed info. I think we expand the stow directory too early on; my assumption when originally implementing this was that the dot- entries would be at the top-level in the stow directory, but this is not the case here. Will do some more digging.

jvkersch avatar Jul 10 '19 12:07 jvkersch

In the mean time, I've been using --target and a separate stow directory for ~/.config as a work around:

stow -v --dotfiles --target=$HOME/.config stow-config

mattmc3 avatar Aug 24 '19 20:08 mattmc3

I have this same structure, one way that works is to keep ~/dotfiles at the root of $ HOME and this command works (@lhindir):

$ (~/dotfiles) stow -R --dotfiles zathura/ -v LINK: .config => laptop/zathura/dot-config

And yes, indeed there is a bug, because in my environment if I try to pass a target it returns this same message:

$ (~/dotfiles) stow -R --dotfiles -t ~ zathura/ -v stow: ERROR: unstow_contents() called with non-directory path: Workspace/git.gutierri.me/laptop/zathura/.config

gutierri avatar Sep 06 '19 00:09 gutierri

I just came across this bug. and read through this issue and #63. It's not a dealbreaker (at least not for my use case), but it would be nice to have this feature working. Is there any ETA for this fix? Thanks!!

NPastorale avatar Jan 28 '20 10:01 NPastorale

Also, stow -D --dotfiles does not seem to work at all, even when files do not contain any "dot-filename" replacements.

We get the to: Planning unstow of package *...done but there is no UNLINK: * when normally unstowing a package.

To echo NPastorale, this would be a great feature. Thanks!

rdrr avatar Mar 29 '20 04:03 rdrr

This attempts to fix this problem: https://github.com/aspiers/stow/pull/70

~I did not test it properly (a very basic use case with a directory) yet. I will test it with a deeper layer of directories.~

I have added some unit tests and the pull requests is building in the CI system. I'm using it locally now also and seems to work.

AitorATuin avatar May 24 '20 16:05 AitorATuin

It would have been lovely to have the limitations of the --dotfiles option in the manual published/released while waiting for the fix to be pushed out

ghost avatar Jun 13 '20 02:06 ghost

It's been more than a year the bug was reported and two months since a fix has been proposed, any updates on this?

samuelhnrq avatar Jul 15 '20 13:07 samuelhnrq

Indeed. Would love to see the fix get merged. 🙏

qbedard avatar Jul 15 '20 15:07 qbedard

Came across the same issue today. Would highly appreciate if the fix got merged.

Also I can help noticing that it has been almost a whole year since the last commit on the master branch. Does the dev team need any help maintaining this project?

queensferryme avatar Jul 29 '20 11:07 queensferryme

Just stumbled on this bug, would be nice if the fix got released.

frelind avatar Aug 10 '20 19:08 frelind

Just hit this too. Any timeline for a fix?

jamieeeeeeeee avatar Jan 02 '21 19:01 jamieeeeeeeee

I got bitten by this one too when use stow to manage my dotfiles(e.g. ~/dotfiles/emacs/dot-emacs.d => ~/.emacs.d).

I found that ensuring the ~/.emacs.d directory doesn't exist(e.g. rm -rf ~/.emacs.d) before running stow --dotfiles emacs can solve this problem.

I don't know why, but it works for me. I use the latest release 2.3.1

han1475 avatar Jan 21 '21 05:01 han1475

It would be nice to have this fixed!

KucharczykL avatar Mar 29 '21 12:03 KucharczykL

This works for now

~/dotfiles on  stow [?]
❯ /usr/local/bin/tree  -l tmux
tmux
└── dot-config -> .config
    └── tmux
        └── tmux.conf

2 directories, 1 file

~/dotfiles on  stow [?]
❯ stow --ignore="^dot-config" tmux

hurricanehrndz avatar Sep 28 '21 03:09 hurricanehrndz

Can this get fixed? It's like 2 years old :(

genevera avatar Nov 10 '21 17:11 genevera

Use chezmoi it does support this out of the box.

Sent from my iPhone

On Nov 10, 2021, at 10:32 AM, genevera @.***> wrote:

 Can this get fixed? It's like 2 years old :(

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

hurricanehrndz avatar Nov 11 '21 13:11 hurricanehrndz

Can we fix this yet? 🙏 Just got hit by this bug today?

  • --dotfiles option for packages with dot-directories/dot-files does not work
  • usual packages with .directories/.files work

raveensrk avatar Nov 23 '21 18:11 raveensrk

I got tired of waiting for this to be merged. *

@AitorATuin would you be ok with me creating an AUR package using your patches? I would eventually remove it if your PR gets merged but until then I would love to have an easy way to install this.

EDIT: the package is now in the AUR as stow-dotfiles-git

*EDIT2: want to apologize about the wording here in case aspiers ever reads it while going through their backlog. I just assumed that he only was in charge of maintaining a mirror, didn't think he was working on it. Hopefully this gets merged and we can stop relying on manually patched versions of stow!

jonathannerat avatar Nov 26 '21 13:11 jonathannerat

@jonathannerat Sure, use it if you want.

AitorATuin avatar Nov 29 '21 07:11 AitorATuin

This issue (and my difficulties trying to figure out what actions stow will take), prompted me to write my own alternative I'm calling fling. It's working well for my personal use; maybe ya'll would like it too :)

bbkane avatar Dec 04 '21 05:12 bbkane

I got bitten by this one too when use stow to manage my dotfiles(e.g. ~/dotfiles/emacs/dot-emacs.d => ~/.emacs.d).

I found that ensuring the ~/.emacs.d directory doesn't exist(e.g. rm -rf ~/.emacs.d) before running stow --dotfiles emacs can solve this problem.

I don't know why, but it works for me. I use the latest release 2.3.1

This works for me too, although in my particular case is isn't a feasible solution. I had to rename a dot-foo directory to .foo instead.

jsf9k avatar Dec 14 '21 16:12 jsf9k

Since a lot of configs are going to be inside ~/.config which will have to exist before stowing the above solution doesn't work.

sudhirkhanger avatar Dec 27 '21 01:12 sudhirkhanger

Not sure if this is much help but I was able to get round the .config issue by nesting my .config folder in a config folder. I then run stow config and it places my nvim folder inside of .config in my home dir. The .config folder itself isn't sym linked but the folders in my dotfiles are.

Screenshot 2022-01-04 at 11 19 41

esslamben avatar Jan 04 '22 11:01 esslamben

I ran into this issue too.

stow directory was setup as

.
└── nvim
    └── dot-config
        └── nvim

I needed to update to following to get my setup to work.

.
└── nvim
    └── .config
        └── nvim

billyogat avatar Jul 15 '22 22:07 billyogat

Thanks to @hurricanehrndz, I just made a workaround for this problem. My workaround includes a .stow-local-ignore instead of using --ignore manually.

(I have a .stowrc with --target=$HOME --dotfiles --verbose)

[~/_dotfiles/stowable]
$ tree -a fish
fish
├── .config -> dot-config
├── .stow-local-ignore
└── dot-config
    └── fish
        ├── config.fish
        ├── ...
        ├── ...
        └── ...........

7 directories, 4 files

[~/_dotfiles/stowable]
$ cat fish/.stow-local-ignore
dot-config

[~/_dotfiles/stowable]
$ stow fish   
LINK: .config/fish => ../_dotfiles/stowable/fish/.config/fish

CrBoy avatar Feb 04 '23 08:02 CrBoy