Using Stow on a Mac

For various reasons, I build some utilities outside of things like MacPorts and Brew, mostly interpreters where I want to ensure that my environment is my environment. I need all of Python, Ruby, and Perl, and sometimes different versions of Ruby as well.

Normally I build with –prefix=$HOME/app/name-maj.min then link app to whatever version I want to be the default. In $HOME/bin I make links to $HOME/pkg/app/bin and mostly everything just works. Except then I started running into problems with man pages, and setting this environment up can be a pain in my login shells. So I went looking for something that automated this. There’s just no other sensible way to do this on a Unix system.

By the way, at (the University of) Waterloo we have a(n) (in)famously obtuse packaging / configuration management system called xhier. Any time I think about this, I wish I had the GOOD parts of said system available. It has lots of nifty toys to automate building, configuration, and managing links, as well as a utility called showpath that helps you to manage both your PATH and MANPATH variables. And I’ve often declared that anybody who thinks about automating, including things like Stow, is at risk of re-inventing xhier.

Stow is a bit of an annoyance in that it, itself, requires Perl. The entire reason I like having my own separate Perl instance, in particular, is because of a long history of CPAN screwing me over. So I put my own version aside, run CPAN, and no operating system update blows my stuff away, and no CPAN will touch my OS stuff. I tried the MacPorts version of Stow and just couldn’t make it cooperate in integrating into my above flow – it would make links just fine in $HOME/stow, but it wouldn’t remove apps.

What finally worked was using my own $HOME/pkg/perl CPAN utility to install Stow. Then I was able to:

cd ~/pkg
stow -t ~/stow ruby-1.9.3
stow -D -t ~/stow ruby-1.9.3

and everything seems to work as expected. The above did not, with the MacPorts version, but it’s still at 1.3 and perhaps there’s issues with the older version, I don’t know. I don’t really like Perl very much any more, so I’m not inclined to delve into the whats wherefores and whys. I thought about looking at how the MacPorts version differed (in configuration) from mine, but then I cracked another beer, drank it and a few more, then laid down for a while and the feeling passed.

(Edited to account for Giles’ grammar correction and general persnickitiness. Thanks, Giles!)

Dealing with MacOS extended file attributes

A year or so ago, I ran into a mysterious issue whereby I couldn’t add new machines to my .ssh/known_hosts file. A few days ago, after restoring from Time Machine “the wrong way” (copying some directories directly out of the filesystem on the Time Machine backup) I ran into them again.

Symptoms: I couldn’t add new host keys to my known hosts file, nor could I remove old ones.

Directory listing:

-rw-r--r--@ 1 me  staff  16588 10 Mar 20:59 .ssh/known_hosts

The trailing @ means the file has extended attributes. After some work with a search engine, I found out I wanted to use the xattr command, or perhaps “ls -lO@”. Either way, the attributes preventing me from modifying the files were:

Running the appropriate incantation of xattr -d on the affected files (it wasn’t just my known_hosts file) worked a treat.