Giter VIP home page Giter VIP logo

Comments (15)

hongyi-zhao avatar hongyi-zhao commented on May 31, 2024 2

Dear aspiers,

Several days before, I've discussed the similar issue as posted in this thread. Now, I give a concrete example as follows:

When using systemd, we may create some customized service unit files, say, I've create the following service unit file just for testing:
werner@debian-01:~/test-systemd$ cat test-systemd.service
[Unit]
Description=test for systemd
[Service]
ExecStart=/usr/bin/env bash -c "echo blabla > %h/1111111"
[Install]
WantedBy=multi-user.target

If I want to use stow to maintain this customized service unit file and put it in the non-standard locations which systemd cann't searches in its path, I must link this file to appropriate location so that systemd can recognize this service.

On the other hand, systemd in itself can only support the absolute path symlinks for such case.

You can see the systemd will create the following absolute symlinks for this service file:

werner@debian-01:~/test-systemd$ systemctl --user enable ~/test-systemd/test-systemd.service
Created symlink from /home/werner/.config/systemd/user/multi-user.target.wants/test-systemd.service to /home/werner/test-systemd/test-systemd.service.
Created symlink from /home/werner/.config/systemd/user/test-systemd.service to /home/werner/test-systemd/test-systemd.service.

So, if using stow to maintain this type of file and create the relative symlinks to the target locations, systemd won't work on this service file.

Regards

from stow.

bricewge avatar bricewge commented on May 31, 2024 2

An other use-case is maintaining a $GIT_TEMPLATE_DIR with stow. Since git will copy the content of $GIT_TEMPLATE_DIR, when initializing a new repo, it copies the relative symlinks to $GIT_DIR all of which will be broken in most cases.

from stow.

someonewithpc avatar someonewithpc commented on May 31, 2024 2

My pull request #68 fixes this, adding a -a/--absolute option for both stowing and unstowing.

from stow.

aspiers avatar aspiers commented on May 31, 2024 1

Yes sure, I'm all for extending Stow in ways that people find useful (regardless of whether I personally find it useful!), as long as it doesn't create any serious technical debt or issues with existing use cases (and I don't expect it would in this case).

I'm incredibly busy at the moment, so this short note is mainly an apology that I can't look at this more closely right now. I tend to process my Stow backlog in batches, ideally every 3-6 months or so (Donald Knuth style) but less often in practice - and the next one is sorely overdue. But if there is a pull request to review at that point which adds this then I'd happily review, otherwise if it looks quick and easy to fix myself then maybe I can do it but no promises!

from stow.

aspiers avatar aspiers commented on May 31, 2024

Interesting idea. Why do you think it would be more efficient?

from stow.

simonvanderveldt avatar simonvanderveldt commented on May 31, 2024

@aspiers Would you consider adding the option to create absolute symlinks? It's the only feature that's in xstow that I miss with GNU stow.

The reason/usecase for me is that I run a lot of development tools in a (Docker) container.
In many cases I need some config inside the container, which can be done with a volume mount of that file, but since that config file is actually a relative symlink created by stow (which goes "up" the hierarchy) the symlink is there but it's impossible to access the real file.
If you need some more info/context just let me know.

from stow.

aspiers avatar aspiers commented on May 31, 2024

I've finally thought about this some more, and need some more info from the people requesting it:

  • I would like to hear from @fourzerofour regarding efficiency concerns.

  • @hongyi-zhao - the systemd use case is interesting but I don't fully understand it yet. Please can you explain why and how you would want to use Stow to manage systemd service files? Do you mean you want to use Stow to install symlinks instead of using systemctl --user enable, or do you mean you want Stow to manage symlinks under ~/test-systemd? It would be very helpful if you gave a full example of exactly what you want Stow to manage, including example paths for all files/symlinks involved.

  • @simonvanderveldt your case is also interesting but again I don't understand it. If you are mounting a config file from a Docker host into a container, even if that config file is an absolute symlink it will still point to a path which the container can't reach. Please could you give a full example of how you want it to work, including example paths for all files/symlinks involved?

  • @bricewge So you want to have a template directory which contains absolute symlinks managed by Stow, so that when you git init using that template directory, your new repository gets the same absolute symlinks pointing to files outside the repository? Why would you want a git repository to contain absolute symlinks which point outside it?

I'm definitely open to Stow being extended to support these use cases, but it's a non-trivial piece of work, so I first want to make absolutely (pun intended) sure that the feature is justified and makes sense. Thanks in advance!

from stow.

bricewge avatar bricewge commented on May 31, 2024

Yes you got it right. I need this to manage my git hooks centrally and not on a per repo basis.
You can see my current use in this package: _template dir and setup.sh are ignored by stowed and allow me to workaround this issue. What I would like to acheive when this issue is resolved is to have _template renamed to .config/git/template which is my git templateDir.

For what I understand the systemd used case submitted by @hongyi-zhao can already be acheived. I'm currently successfully using stow to manage user services under systemd 239 that are enabled by default.You can found part of my setup here and following is an example of it working:

$ tree  ~/.config/systemd/
/home/bricewge/.config/systemd/
└── user
    ├── graphical-session.target.wants
    │   └── [email protected] -> ../../../../project/dotfiles/bspwm/.config/systemd/user/graphical-session.target.wants/[email protected]
    ├── [email protected] -> ../../../project/dotfiles/bspwm/.config/systemd/user/[email protected]
    └── tmux.service -> ../../../project/dotfiles/tmux/.config/systemd/user/tmux.service
$ systemctl --user status [email protected][email protected] - Poybar, create a status bar per monitor
   Loaded: loaded (/home/bricewge/.config/systemd/user/../../../project/dotfiles/bspwm/.config/systemd/user/[email protected]; disabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-06-22 17:59:37 CEST; 5 days ago
 Main PID: 2703 (polybar)
   CGroup: /user.slice/user-3013.slice/[email protected]/polybar.slice/[email protected]
           ├─2703 /run/current-system/sw/bin/polybar --reload example
           ├─2716 sh /home/bricewge/.local/bin/mpvctl.sh
           ├─2735 sh /home/bricewge/.local/bin/mpvctl.sh
           └─2736 /bin/sh /home/bricewge/.local/bin/mpvctl prop filtered-metadata
[...]

from stow.

aspiers avatar aspiers commented on May 31, 2024

Thanks a lot for the quick reply @bricewge! I'm not sure I'm any closer to understanding why the feature requested in this issue is needed though:

@bricewge commented on June 28, 2019 3:25 PM:

Yes you got it right. I need this to manage my git hooks centrally and not on a per repo basis.
You can see my current use in this package: _template dir and setup.sh are ignored by stowed and allow me to workaround this issue.

Sorry, maybe I'm being stupid but I still don't get it. What is the issue exactly, and how do they work around it?

What I would like to acheive when this issue is resolved is to have _template renamed to .config/git/template which is my git templateDir.

What's stopping you doing that right now?

For what I understand the systemd used case submitted by @hongyi-zhao can already be acheived. I'm currently successfully using stow to manage user services under systemd 239 that are enabled by default.You can found part of my setup here and following is an example of it working:

$ tree  ~/.config/systemd/
/home/bricewge/.config/systemd/
└── user
    ├── graphical-session.target.wants
    │   └── [email protected] -> ../../../../project/dotfiles/bspwm/.config/systemd/user/graphical-session.target.wants/[email protected]
    ├── [email protected] -> ../../../project/dotfiles/bspwm/.config/systemd/user/[email protected]
    └── tmux.service -> ../../../project/dotfiles/tmux/.config/systemd/user/tmux.service
$ systemctl --user status [email protected][email protected] - Poybar, create a status bar per monitor
   Loaded: loaded (/home/bricewge/.config/systemd/user/../../../project/dotfiles/bspwm/.config/systemd/user/[email protected]; disabled; vendor preset: enabled)
   Active: active (running) since Sat 2019-06-22 17:59:37 CEST; 5 days ago
 Main PID: 2703 (polybar)
   CGroup: /user.slice/user-3013.slice/[email protected]/polybar.slice/[email protected]
           ├─2703 /run/current-system/sw/bin/polybar --reload example
           ├─2716 sh /home/bricewge/.local/bin/mpvctl.sh
           ├─2735 sh /home/bricewge/.local/bin/mpvctl.sh
           └─2736 /bin/sh /home/bricewge/.local/bin/mpvctl prop filtered-metadata
[...]

Right, so why is there a need for Stow to be enhanced to support this further?

from stow.

bricewge avatar bricewge commented on May 31, 2024

I apologize, I wasn't clear enough it only doesn't works when using --no-folding. Flowing is an example to reproduce my issue with git templates.

  1. We setup the stow package:
$ mkdir stow-3
$ mkdir -p .config/git/template/hooks
$ echo "#/usr/bin/env polybar --help sh\necho foo" > stow-3/.config/git/template/hooks/pre-commit
$ chmod +x  stow-3/.config/git/template/hooks/pre-commit
$ stow --target ~ stow-3 --verbose --no-folding
MKDIR: .config/git/template
MKDIR: .config/git/template/hooks
LINK: .config/git/template/hooks/pre-commit => ../../../../tmp/stow-3/.config/git/template/hooks/pre-commit
  1. Creating a repo at the same level as the package will work:
$ cat -A repo/.git/hooks/pre-commit
#/usr/bin/env polybar --help sh$
echo foo$
$  ls -alh repo/.git/hooks/pre-commit
lrwxrwxrwx 1 bricewge users 60 06-28 16:48 repo/.git/hooks/pre-commit -> ../../../../tmp/stow-3/.config/git/template/hooks/pre-commit
  1. But creating a repo on an other level the hook will be a broken symlink:
$ cd /tmp
$ git init --template ~/.config/git/template repo
Initialized empty Git repository in /home/bricewge/tmp/repo/.git/
$ cat -A repo/.git/hooks/pre-commit
cat: repo/.git/hooks/pre-commit: No such file or directory
$ ls -alh repo/.git/hooks/pre-commit
lrwxrwxrwx 1 bricewge users 60 06-28 16:50 repo/.git/hooks/pre-commit -> ../../../../tmp/stow-3/.config/git/template/hooks/pre-commit

Sorry, maybe I'm being stupid but I still don't get it. What is the issue exactly, and how do they work around it?

My workaround is a stupid script that get executed after stow because I'm using wrapper to run it.

Right, so why is there a need for Stow to be enhanced to support this further?

There is no need for it for using stow to manage systemd user services as far as I understand but it still seems needed to manage git template directories.

from stow.

aspiers avatar aspiers commented on May 31, 2024

Ohhhh I see, so you want the pre-commit hooks to symlink to hook files defined under a Stow package, and since git init can be run from anywhere and makes exact copies of the symlinks from the template dir managed by Stow, those symlinks need to be absolute. Got it now, thanks a lot!

from stow.

aspiers avatar aspiers commented on May 31, 2024

So far this (git template directories) is the only use case which makes sense to me, but if anyone else can suggest others I'd love to hear them.

from stow.

thibaultcha avatar thibaultcha commented on May 31, 2024

This would be great to have - any chance #68 could get some attention in the near future? Stow has solved all of my issues with dotfiles management so far except for this use-case.

from stow.

someonewithpc avatar someonewithpc commented on May 31, 2024

A merge bot complains about code coverage having decreased, but I don't know how to fix it in Perl

from stow.

aspiers avatar aspiers commented on May 31, 2024

Thanks a lot @someonewithpc! I will definitely take a look at this, hopefully soon. I have a big backlog of Stow maintenance which I've been meaning to attend to for a long time already. The code coverage decreasing is not Perl-specific, it just means you haven't added tests for the new functionality - please take a look at t/*.t and copy the style of the existing tests.

from stow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.