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

Can GNU Stow use a stow target directory that is a symbolic link? #83

Open
issenn opened this issue Mar 27, 2021 · 2 comments
Open

Can GNU Stow use a stow target directory that is a symbolic link? #83

issenn opened this issue Mar 27, 2021 · 2 comments

Comments

@issenn
Copy link

issenn commented Mar 27, 2021

mkdir -p /usr/local/Cellar/app/0.36.2/{bin,etc}

touch /usr/local/Cellar/app/0.36.2/{LICENSE,README.md}
touch /usr/local/Cellar/app/0.36.2/bin/cmd

ln -s  /usr/local/Cellar/app/0.36.2  /usr/local/opt/app


mkdir -p ~/dotfiles/app-config/opt/app/

touch  ~/dotfiles/app-config/opt/app/homebrew.mxcl.app.plist

cd ~/dotfiles/app-config/opt/
stow -v5 -n --no-folding --dir=. --target=/usr/local/opt/

Output

  read_a_link(app): real link
  Evaluate existing link: app => ../Cellar/app/0.36.2
  is path ../Cellar/app/0.36.2 owned by stow?
    no - either ../Cellar/app/0.36.2 not under ../../../Users/issenn/dotfiles/app-config/opt or vice-versa
CONFLICT when stowing .: existing target is not owned by stow: app
@aspiers
Copy link
Owner

aspiers commented Apr 8, 2021

Sorry I can't reproduce this. I get:

stow: No packages to stow or unstow

which is also unsurprising because the stow command didn't specify which package to stow. But even if I guess that the package to stow was app, then I can't reproduce the error since it works fine for me. The output you pasted doesn't seem to match the commands listed for reproduction. For example,

Evaluate existing link: app => ../Cellar/app/0.36.2

indicates a relative symlink, but your setup creates absolute symlinks. Please can you paste the exact sequence of commands you used, and the full output from Stow, not just select lines?

@issenn
Copy link
Author

issenn commented Apr 10, 2021

@aspiers Sorry, I missed the package name. I reproduced it again, this is my script and output log.

#!/usr/bin/env sh


base_dir="$(dirname -- "$(realpath $0)")"/stow-test-symbolic-link

target="${base_dir}"

app_name="app"
app_ver="0.36.2"

rm -rf "${base_dir}"

echo "${base_dir}" "${app_name}" "${app_ver}"

mkdir -p "${base_dir}"/{Cellar,opt,etc,dotfiles}

# create source file with version
mkdir -p "${base_dir}"/Cellar/"${app_name}"/"${app_ver}"/{bin,etc}

touch "${base_dir}"/Cellar/"${app_name}"/"${app_ver}"/{LICENSE,README.md}
touch "${base_dir}"/Cellar/"${app_name}"/"${app_ver}"/bin/cmd
touch "${base_dir}"/Cellar/"${app_name}"/"${app_ver}"/etc/cmd.conf.example

# create symbolic link folder without version
ln -snf "${base_dir}"/Cellar/"${app_name}"/"${app_ver}" "${base_dir}"/opt/"${app_name}"


# create app config in dotfiles
mkdir -p "${base_dir}"/dotfiles/"${app_name}"-config/{opt,etc}/"${app_name}"

touch "${base_dir}"/dotfiles/"${app_name}"-config/opt/"${app_name}"/homebrew.mxcl."${app_name}".plist
touch "${base_dir}"/dotfiles/"${app_name}"-config/etc/"${app_name}"/cmd.conf

echo ""
echo "########################################################################"
echo "########## file structure - before stow                       ##########"
echo "########################################################################"
echo ""

tree -a "${base_dir}"

echo ""
echo "########################################################################"
echo "########## stow use target directory that is normal directory ##########"
echo "########################################################################"
echo ""

stow -S --no-folding --dir="${base_dir}"/dotfiles/"${app_name}"-config/opt --target="${target}"/opt/"${app_name}" "${app_name}"
[[ -d "${target}"/etc/"${app_name}" ]] || mkdir "${target}"/etc/"${app_name}"
stow -S --no-folding --dir="${base_dir}"/dotfiles/"${app_name}"-config/etc --target="${target}"/etc/"${app_name}" "${app_name}"

tree -a "${base_dir}"

stow -D --no-folding --dir="${base_dir}"/dotfiles/"${app_name}"-config/opt --target="${target}"/opt/"${app_name}" "${app_name}"
stow -D --no-folding --dir="${base_dir}"/dotfiles/"${app_name}"-config/etc --target="${target}"/etc/"${app_name}" "${app_name}"

echo ""
echo "########################################################################"
echo "########## stow use target directory that is a symbolic link  ##########"
echo "########################################################################"
echo ""

# "${target}"/opt/"${app_name}" is a symbolic link
stow -S -v5 -n --no-folding --dir="${base_dir}"/dotfiles/"${app_name}"-config --target="${target}"/opt opt
[[ -d "${target}"/etc/"${app_name}" ]] && rm -rf "${target}"/etc/"${app_name}"
stow -S --no-folding --dir="${base_dir}"/dotfiles/"${app_name}"-config --target="${target}"/etc etc

tree -a "${base_dir}"

# stow -D -v5 -n --no-folding --dir="${base_dir}"/dotfiles/"${app_name}"-config --target="${target}"/opt opt
stow -D --no-folding --dir="${base_dir}"/dotfiles/"${app_name}"-config --target="${target}"/etc etc

output.log

/Users/issenn/Downloads/aaaa/stow-test-symbolic-link app 0.36.2

########################################################################
########## file structure - before stow                       ##########
########################################################################

/Users/issenn/Downloads/aaaa/stow-test-symbolic-link
├── Cellar
│   └── app
│       └── 0.36.2
│           ├── LICENSE
│           ├── README.md
│           ├── bin
│           │   └── cmd
│           └── etc
│               └── cmd.conf.example
├── dotfiles
│   └── app-config
│       ├── etc
│       │   └── app
│       │       └── cmd.conf
│       └── opt
│           └── app
│               └── homebrew.mxcl.app.plist
├── etc
└── opt
    └── app -> /Users/issenn/Downloads/aaaa/stow-test-symbolic-link/Cellar/app/0.36.2

14 directories, 6 files

########################################################################
########## stow use target directory that is normal directory ##########
########################################################################

/Users/issenn/Downloads/aaaa/stow-test-symbolic-link
├── Cellar
│   └── app
│       └── 0.36.2
│           ├── LICENSE
│           ├── README.md
│           ├── bin
│           │   └── cmd
│           ├── etc
│           │   └── cmd.conf.example
│           └── homebrew.mxcl.app.plist -> ../../../dotfiles/app-config/opt/app/homebrew.mxcl.app.plist
├── dotfiles
│   └── app-config
│       ├── etc
│       │   └── app
│       │       └── cmd.conf
│       └── opt
│           └── app
│               └── homebrew.mxcl.app.plist
├── etc
│   └── app
│       └── cmd.conf -> ../../dotfiles/app-config/etc/app/cmd.conf
└── opt
    └── app -> /Users/issenn/Downloads/aaaa/stow-test-symbolic-link/Cellar/app/0.36.2

15 directories, 8 files

########################################################################
########## stow use target directory that is a symbolic link  ##########
########################################################################

stow dir is /Users/issenn/Downloads/aaaa/stow-test-symbolic-link/dotfiles/app-config
stow dir path relative to target /Users/issenn/Downloads/aaaa/stow-test-symbolic-link/opt is ../dotfiles/app-config
cwd now /Users/issenn/Downloads/aaaa/stow-test-symbolic-link/opt
cwd restored to /Users/issenn/Downloads/aaaa
cwd now /Users/issenn/Downloads/aaaa/stow-test-symbolic-link/opt
Planning stow of package opt...
. not protected
Stowing contents of ../dotfiles/app-config/opt (cwd=~/Downloads/aaaa/stow-test-symbolic-link/opt)
  => ../dotfiles/app-config/opt
  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
  ../dotfiles/app-config/opt/.stow-local-ignore didn't exist
  Using ignore file: /Users/issenn/.stow-global-ignore
    Ignore list regexp for paths:    /(?^:(^|/)(^/COPYING|^/\.stow\-local\-ignore$|^/README.*|^/LICENSE.*|^/@.*)(/|$))/
    Ignore list regexp for segments: /(?^:^(\.gitkeep|\.svn|\.git|\.hg|\.gitmodules|.*.swp|_darcs|\.cvsignore|RCS|\.DS_Store|.*\.md|#.*#|.+~|CVS|\.gitignore|.+,v|.*.example|\.#.+)$)/
  Not ignoring app
Stowing ../dotfiles/app-config / opt / app
  => ../dotfiles/app-config/opt/app
  is_a_link(app)
  link_task_action(app): no task
  is_a_link(app): is a real link
    parent_link_scheduled_for_removal(app): prefix app
    parent_link_scheduled_for_removal(app): returning false
  link_task_action(app): no task
  read_a_link(app): real link
  Evaluate existing link: app => /Users/issenn/Downloads/aaaa/stow-test-symbolic-link/Cellar/app/0.36.2
  is path /Users/issenn/Downloads/aaaa/stow-test-symbolic-link/Cellar/app/0.36.2 owned by stow?
BUG in find_stowed_path? Absolute/relative mismatch between Stow dir ../dotfiles/app-config and path /Users/issenn/Downloads/aaaa/stow-test-symbolic-link/Cellar/app/0.36.2 at /usr/local/Cellar/stow/2.3.1//Library/Perl/5.18/Stow.pm line 966.
    no - either /Users/issenn/Downloads/aaaa/stow-test-symbolic-link/Cellar/app/0.36.2 not under ../dotfiles/app-config or vice-versa
CONFLICT when stowing opt: existing target is not owned by stow: app
Planning stow of package opt... done
cwd restored to /Users/issenn/Downloads/aaaa
WARNING! stowing opt would cause conflicts:
  * existing target is not owned by stow: app
All operations aborted.
/Users/issenn/Downloads/aaaa/stow-test-symbolic-link
├── Cellar
│   └── app
│       └── 0.36.2
│           ├── LICENSE
│           ├── README.md
│           ├── bin
│           │   └── cmd
│           └── etc
│               └── cmd.conf.example
├── dotfiles
│   └── app-config
│       ├── etc
│       │   └── app
│       │       └── cmd.conf
│       └── opt
│           └── app
│               └── homebrew.mxcl.app.plist
├── etc
│   └── app
│       └── cmd.conf -> ../../dotfiles/app-config/etc/app/cmd.conf
└── opt
    └── app -> /Users/issenn/Downloads/aaaa/stow-test-symbolic-link/Cellar/app/0.36.2

15 directories, 7 files

I don't want to create stow link for the directory, but to create stow link for all files.

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