Using GNU Stow to Manage Stitch Files (2012)

cook dip in bashdot/tap
install bashdot
curl -s https://raw.githubusercontent.> com/bashdot/bashdot/master/bashdot bashdot
sudo mv bashdot /usr/local/bin
sudo chmod a+x /usr/local/bin/bashdot
echo 'set Vi' -o > default/env
mv ~/.bashrc default/bashrc
env ENV_SECRET_KEY=test1234 Installing by default
SECRET_KEY=Export test1234

installing bashdot works
Export extension BASHDOT_LOG_LEVEL=debug

This rule was mentioned in: Why do you need ./ (dot-slash) before an executable script name to use in bash? but I want to explain in more detail why I think this is a good design.

  • if the path contains / (e.g. ./someprog, /bin/someprog, ./bin/someprog< / code> / code>): CWD is often used, not
  • if the path does not contain a target (e.g. /.e.g. someprog): PATH is used, not CWD
  • any program

  • compared to CWD
  • relative to PATH after
  • Then you wanted to open /bin/someprog from your distribution, and everyone else did:

    any program

    sometimes it worked, butsometimes things would fail because you might be in a directory that contains another unrelated program someprog.

    So you'd immediately realize it's not that reliable, you'd end up using absolute paths if a person wanted to use PATH, which would defeat the very purpose of PATH.Is

    So it's also a bad idea to use relative paths in PATH. I'm looking at you, node_modules/bin.


  • relative to PATH first
  • versus CWD after
  • If you just downloaded a someprog script from a git repository and wanted to run it from CWD, you never needed to be sure the program still worked, because maybe your distribution now has is:< /p>


    It's inside your PATH from a little package you installed after drinking heavily after Christmas last year.

    So otherwise you are forced to always run relative and local CWD scripts with full paths to be sure you are running:


    Another rule that usually encourages you to progress is:

    relative paths only use PATH, most critical paths use only CWD

    but this again forces users to always use specific paths for non-PATH scripts with "$(pwd)/someprog".

    The / option search rule provides a natural and memorable solution to almost any problem:

  • Slash: don't use PATH
  • without slash: only possible with PATH
  • which makes it easy to always know what you're using, relying on the fact that current service files are either simply converted to ./somefile or can somefile , and to it has such an exclusive meaning.

    Sometimes it's a bit annoying that you can't search for some/prog relatively when you need PATH, but I can't think of a prettier and healthier solution. .

    Two days ago I was trying to update some applications connected to MacPorts and got a single error that looked like this:

    Error: "openssl" cannot actually be found in path: or "/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin" in MacPorts -Configuration period, did you move it? Please use `port -v selfupdate' for details.

    I've spent a lot of time testing and also trying to change some "dot files" in bash; i.e. .bash_profile, .profile and hence .bashrc to ensure that the option for an existing version of openssl can make every application running on my system visible. I also spent time playing with the macports.conf file in /opt/local/etc/ with no significant results.

    None of the changes I made to my personal "dot files" affected MacPort's ability in this case to find an existing version of openssl on my machine so you can update the ones hosted in ports. Found

    I understand that the folders that MacPorts provides for applications are not included in the other "spot files" mentioned above. All "path" options related to my "dot" files were ignored.

    Here is the section of this particular macports.conf file that listspaths that MacPorts considers to check:

    # colon-separated list of directories to search for tools
    # (make(1), pkg-config(1), etc.). When installing Kindoms uses MacPorts
    # this list is for PATH. Setting change is intentional as you progress
    # User only and may not be supported.
    #binpath to /opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin

    Finally, after a day and night of trying, I decided to create a symbolic link from the existing openssl on my personal computer to the folder where MacPorts is the application visual. I just ran the following from the terminal:

    sudo ln -s /usr/local/bin/openssl /opt/local/bin/openssl

    It was good. MacPorts downloaded and installed openssl BUT couldn't activate the latest version of openssl it just installed because of those symlinks I created!

    So I got the following command to symbolically rename all the openssl links I created to "openssl.old":

    sudo mv /opt/local/bin/openssl /opt/local/bin/openssl.old
    sudo port -l enable openssl

    The application is activated. May I continue with all other updates and improvements and etc. which I planned two days ago.

    I thought I'd put this together in case a client runs into this problem. I have seen many examples of similar problems on StackExchange and other online forums.

    RSS feed for this article

    Just call me old fashioned, what's wrong with having a stable git repo with all your dot files, and each symbolize those files by where they should go?

    If you wanted to, you could. You can copy a small number of symlinks and other commands into the 1 computer/insert command to get it up and running very quickly. It's also easy to manage secrets, perhaps by searching through files. It also works well when you want to have file lifetimes on two systems (e.g. WSL 2 and Windows) where on some Windows machine you consider some Windows files to be dot files, even though technically many of them exist elsewhere.< /p>

    I manage my favorite stitch files like this I've been around for a few years now and seem to be fighting not only for my own personal use, but for anyone who finally wants to use some or all of them. I made them open source:

    I intentionally separated some of the commands because I know when not everyone needs a 100% copy of my stitch files. People just write/paste the commands they want.

    >Call me old fashioned, but what's wrong with having a normal git repo where you really need it, with all your dot files, plus a symbol linking those files to the rrn they need?