November 14, 2012 5:30 AM   Subscribe

Development on OSX. I lots of kiddie-pool programming experience, but I'm starting to do learn web dev and working with frameworks is leading to a lot of confusion regarding paths, dependencies, permissions, and file structure. What's a good resource that lays out the "how & why"?

I have so many questions that I think the problem's that I lack an understanding of the osx file structure paradigm. Need to know the reasoning behing all this stuff so I can act in accordance with it.

Here's a few things I've been wondering, to give you a flavor:
Why the distinction between root and user(home), when I'm the only one using this machine?
What types of things should I do for convenience and efficiency, what things should I do to prevent me from accidentally screwing things up?

What should my home folder look like?

When is it kosher (and when is it not) to move directories around? Dependencies, permissions, where is stuff "supposed" to go?

mymachine$ ls ---->
dev etc bin sbin usr
What's in all these directories and why?

Also, if I was to widen the scope a little bit: I for example didn't know what a package manager was until a few weeks ago when I installed Django for the first time. I know learning by doing is the best way -- but I want the cheat-sheet for what tools (web) developers use and take for granted.
posted by victory_laser to Computers & Internet (10 answers total) 10 users marked this as a favorite
This book looks like a good introduction to the kind of things you are asking.

Probably best to leave bin, etc, etc. alone until you are sure what you are doing and why.
posted by thelonius at 5:36 AM on November 14, 2012

How different is Mountain Lion from Lion when it comes to this? I'm stuck with Lion at the moment because my machine is old. There's books on Unix+OSX for Lion by other authors/publishers, though.

I will take your advice, except that adding stuff to the path is pretty routine, no?
posted by victory_laser at 5:47 AM on November 14, 2012

For web development on OSX, I recommend a few things:

1. OSX Dotfiles from mathiasbynens. They have a lot of tweaks to the UI, and some very nice command line changes and tools.
2. Home Brew for packages - install php, mysql, git, mercurial, and anything else with it. This will keep you from dealing with bin/sbin and paths (mostly).
3. Mac Vim with SPF13 makes a great editor. If you're new to VIM, learn it without the SPF tools first.

With all that said - I don't install or use Apache or MySQL on OSX anymore. I use Vagrant to do all my development in a virtual machine. If you're hosting on Linux, then OSX is very close but not identical to your production environment. With Vagrant, you can have an identical server and script the build. Vagrant is great because you can check the config into your source code control and then spin up a development instance in minutes from any machine.

And, last but not least: EVERYTHING goes into source control. Projects, dotfiles, code snippets - You can even use the GitHub Mac Client.
posted by tumble at 6:17 AM on November 14, 2012 [2 favorites]

Do you want to learn just enough to get by enough to not screw things up, or do you want to really learn what's going on?

For the latter, don't learn OSX specific stuff. Learn Linux. Get virtual box, install Ubuntu, and learn it's directory structure and why things are where they are. Read books, try to install things from source, build your own development server. Get really familiar with ssh as well.

OSX is, at it's origins, is based of of BSD Unix. Most Linux distributions are also close enough to their unix roots that switching between distributions is pretty easy. Once you understand Linux, OSX under the hood will just intuitively make sense for the most part. PATHs, bin directories, etc - they all have their origins in unix and will continue forever in Linux and most likely OSX operating systems.

On the other hand, if you just want to learn enough not to destroy things, I suggest virtual environments (virtualenv, etc for python, rvm for ruby, and although not truly a virtual env, even using something like composer and packagist for php is helpful.). This will keep your base OSX install "clean" so that each project is it's own environment and wont trample on each other with conflicting dependancies.

Other than that, I'd go with the safe standby that if you don't what what it does, simply don't screw with it. Use source control for *everything* (i prefer git) and then just learn by doing.

Good luck and have fun!
posted by cgg at 7:29 AM on November 14, 2012

A few things to keep in mind:

1) OSX is UNIX, but it keeps a lot of its software in non-standard places and configures common apps similarly. I second tumble's suggestion of Homebrew, and start from scratch. As a developer, don't rely on any of OSX's built-in executables.

2) Even in the non-OSX world of UNIX, things get messy with regards to directories like /etc and /opt and /var, which are vaguely-defined guidelines for organizing "other stuff". The reality is that they're all going to get crapped up with installed software based on the whims of the devs.

3) Get familiar with dotfiles on Github. Basically, they're configuration settings for your command line, and a lot of them are public and really useful.

4) As a single user, the actual real-life difference between root and user is fairly small, but avoid the temptation to "hang out" as root. Sandboxing user security is something that Really Matters in UNIX.
posted by mkultra at 7:42 AM on November 14, 2012

Pro web developer here. You don't actually need to know this stuff. It isn't part of the job description.

For the server:

This is what sysadmins and managed hosting are for. If you don't have access to either, you still probably aren't hosting on a Mac, so you don't need to know the answers to these questions on OSX--you'd want to learn about Linux.

And, again, this isn't part of your job description as a web developer. I'm the lone tech guy/programmer/admin/etc for a design firm with 10+ years experience, and I am still a shitty sysadmin. We got through the first five years by relying on control panels like Plesk and the admins at our hosting providers. Now we use quasi-premium managed hosting like Heroku and WPEngine for better results without me having to learn a whole other field of expertise.

For your workstation:

This is what Homebrew is for. Rather than needing to know how to install and troubleshoot things like apache, mysql, imagemagick, git, redis etc, you run simple commands like "brew install imagemagick".

And tools like Homebrew are only necessary if you're getting into some pretty serious development. If you're just hacking together some LAMP sites, MAMP is a lovely solution. Double click it and you've got apache, mysql, php etc all running. Quit it and they're gone. Heroku's Postgres.app is similarly excellent (albeit with a smaller scope).

I should also note that the kinds of tools you'll need to know vary depending on what programming environment you're using. I use mostly PHP and Rails, so that's what I know. If you're a Python developer, there could be other advice you should be following.
posted by tsmo at 9:17 AM on November 14, 2012 [1 favorite]

For a lot of these technologies, it's very important to understand what problem they're trying to solve. Git, Homebrew, RVM (and rb-env :D), dotfiles all try to solve pretty specific problems. It might even be helpful to have an installation of Linux where you can muck around and do things incorrectly as much as you want. Then, when you start using version control, virtual environments, and package managers, you'll have experienced the problems that they were trying to solve.

Also, Unix is gigantic and most developers only know probably less than half of it. You can ask "What types of things should I do for convenience and efficiency" five times and get five very different answers. I do some basic stuff like:

- ssh keys: never type an ssh password again.
- vim shortcuts
- tabs
- learn git, really well. I've spent so many hours wrestling git to figure out a problem that would take me 5m to solve today.
posted by yaymukund at 6:11 PM on November 14, 2012

If you are working with Python, look up virtualenv so you can potentially manage different versions of Python packages between different projects.

I usually keep my various projects in /Users/username/Projects/* in OS X.
posted by xtine at 8:12 PM on November 14, 2012

And if you're looking for other tools, I recommend:

- Sublime Edit. It's a text editor. vim is great, too, but has a ludicrous learning curve, and you may not have that kind of time.

- iTerm. Some people prefer it to the built in Terminal. But I recommend waiting until the built-in Terminal seems to be slowing you down before you jump ship (same with customizing your dotfiles).

- Git. As suggested by several above. `brew install git`. Git is hard to use, but it sucks less than svn and has become something of an industry standard (see: github). Feel free to use a GUI instead of the command line tool for the time being--just know that the command line is vastly more powerful.

- Transmit. FTP client. If you need one. (And if you're using git, you hopefully won't need one, because you'll be deploying via ssh + git pull, not via ftp). If you're a lazy bastard and not using version control, you can even use Coda: the best tool for recklessly live-editing files on your production server.

- VirtualBox + ievms. Virtual machines so you can test your apps under goddamn IE.

- On The Job. Simplest possible time tracker. For your invoices. Billings is probably better, though.
posted by tsmo at 9:59 AM on November 15, 2012

I don't have a reference for you -- I got to learn all this stuff the hard way!

Why the distinction between root and user(home), when I'm the only one using this machine?

'root' is the superuser. It's very dangerous to run things as root because it has full access to everything on your system. That's why your own account is separate.

In OSX it typically shouldn't be necessary to use the root account very often. If you do, just use 'sudo'.

What types of things should I do for convenience and efficiency, what things should I do to prevent me from accidentally screwing things up? When is it kosher (and when is it not) to move directories around? Dependencies, permissions, where is stuff "supposed" to go?

You shouldn't normally need to worry about this. Personally I just keep most everything in my home directory, except for Homebrew packages which go in /usr/local.

Keep in mind that OSX is a bit two-faced about directory structure. You can see everything via the command line, but in Finder and GUI apps you won't normally be able to access /usr, /bin, /etc, &c. So it's doubly not a good idea to keep important stuff in there.

What should my home folder look like?

Whatever you want. You should probably leave the default OSX directories alone, of course.

How different is Mountain Lion from Lion when it comes to this?

Lion and Mountain Lion are nearly identical outside of Apple's first-party apps. When I upgraded I just had to upgrade Xcode and reinstall a couple of finicky Homebrew packages.

Tools to use:
- Virtualbox for VM testing. You might want to mess around with a Linux VM if you're interested in commandline stuff. Do keep in mind, as noted above, that OSX's built-in commandline tools are a bit different from the equivalent Linux ones.
- iTerm2 for command line, maybe. I think Terminal is fine myself, but some people I know prefer it.
- Sublime Text is really nice for code editing. And pretty, too! As a Windows user I used to lament that Notepad++ wasn't available for Mac until I discovered ST.
- Homebrew for package management. There's competition in this area (MacPorts and Fink) but Homebrew is much saner in my opinion. There are tons of packages available that make life easier for web developers -- imagemagick, (updated versions of) git, current PHP, current Python, lint, tidy, ffmpeg, etc.
- Git. You have the power, use it! (Seriously, Git is great software, yet all the GUI apps for it suck terribly. Learn the command line instead. Atlassian SourceTree is the only non-terrible GUI Git app I've seen, but I only use it to visualize branches. I really have no idea how Windows users cope without resorting to Cygwin.)
posted by neckro23 at 2:11 PM on November 15, 2012

« Older Recommend a good portable battery pack?   |   A pan without a lid is like a pan without a lid. Newer »
This thread is closed to new comments.