1

I'm migrating to OSX and need to figure out when to keep my scripts and libraries. I have code in Perl and Python, and libraries I've written in both languages. I am the only user of this machine so I imagine the difference between, ~/bin/ and /usr/local/bin/ is less clear than on a multi-user machine.

I'm not sure what the correct layout of such files is under Unix (even after poking around, e.g., here) and even less so under OSX's nonstandard arrangement.

Where should I put the scripts that I actually run? In ~/bin/? In /usr/local/bin/? Should I segregate the Python and Perl in, say, ~/bin/python/ and ~/bin/perl/?

And (harder I think) where should I put the libraries? In ~/lib/? In ~/lib/python/ and lib/perl/? Or somewhere in ~/Library/?

kuzzooroo
  • 275
  • 3
  • 12
  • Note for future Googlers: the information in the link about Apple's "nonstandard arrangement" is out of date. See [here](https://superuser.com/questions/7150/mac-os-x-conventional-places-where-binary-files-should-live/7163?noredirect=1#comment2079827_7163). – Telemachus Dec 01 '18 at 15:48

1 Answers1

1

If you want to maintain compatibility with other Unix/Linux systems, you should use /usr/local/bin and /usr/local/lib, even though you're the only user on the machine. The Filesystem Hierarchy Standard indicates that the /usr/local hierarchy:

is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated. It may be used for programs and data that are shareable amongst a group of hosts, but not found in /usr.

Locally installed software must be placed within /usr/local rather than /usr unless it is being installed to replace or upgrade software in /usr.

Technically, if the programs are only for your own use, you could use ~/bin, ~/lib, etc., but I usually reserve those directories for when I'm a non-admin user on a shared machine (on my web host, for example).

As far as segregating based on language, the binaries should all be in /usr/local/bin, but libraries can be in /usr/local/lib/perl5, /usr/local/lib/python3.3, etc.

MattDMo
  • 5,309
  • 24
  • 30