Homebrew El Capitan

Mon 02 November 2015 —Filed under notes; tags: mac
  1. I just upgraded to El Capitan, and when I tried updating brew I got the following error: $ brew update Error: The /usr/local directory is not writable. Even if this directory was writable when you installed Homebrew, other software may change permissions on this directory.
  2. Installing Homebrew on Mac OS X prior to El Capitan (that is Yosemite, Mavericks and others) used to be a breeze. But with a new change in OS X El Capitan called SIP - installing Homebrew has become a bit complicated. You need not worry, I have got you covered. There are two parts to this tutorial.
  3. Homebrew complements macOS (or your Linux system). Install your RubyGems with gem and their dependencies with brew. “To install, drag this icon” no more. Homebrew Cask installs macOS apps, fonts and plugins and other non-open source software. $ brew install -cask firefox. Making a cask is as simple as creating a formula.
  4. Installing Homebrew on Mac OS X El Capitan used to be a easy. But with a new change in OS X El Capitan called SIP (System Integrity Protection) - installing Homebrew has become a bit complicated. STEP 1: Permission Issues /usr/local/ (A) If you are updating El Capitan from a previous OS.

Sep 29, 2016 Due to SIP restriction, the old HomeBrew (Migrated from Yosemite or older macOS) does not work well on El Capitan (and newer).

Table of Contents

  • First applications
  • system-level configuration
  • homebrew
  • ssh

I had enough issues after updating to El Capitan (the inability to save mywifi password in the system keychain was the tipping point) that Idecided to perform a clean install. Here are some notes.

First applications

Developer tools

Pretty much the first thing any mac needs is the command line tools. This can be done from the command line:

X11

Download and install Xquartz:

Note for next time: might be worth trying to use homebrew.

X11 key bindings so that the option key is used for Meta..

iTerm2

Update a few settings.

Preferences –> Profiles –> Keys and do these things:

  • select 'Left/right option key acts as': +Esc
  • + –> Keyboard shortcut 'OPT+<left arrow>': Send Escape sequence 'b'
  • + –> Keyboard shortcut 'OPT+<right arrow>': Send Escape sequence 'f'

Default appearance:

  • Preferences –> Profiles –> Colors –> Load Presets –> Light Background
  • Preferences –> Profiles –> Text –> Change Font –> 14 point
Homebrew osx el capitan

Others

  • Dropbox
  • SizeUp - http://www.irradiatedsoftware.com/ (license in Dropbox/software_licenses)
  • MacTex - download from http://tug.org/mactex/http://mirror.ctan.org/systems/mac/mactex/MacTeX.pkg
  • HipChat client
  • Chrome
  • Dash 2 (App store)

UW only

  • Sophos antivirus: https://softy.cac.washington.edu/sophos/for-staff/
  • Junos Pulse (SSL VPN): https://networks.uwmedicine.org/content/sslvpn-frequently-asked-questions-14

system-level configuration

turn off spelling autocorrect

System Preferences –> Language & Text –> Text tab –> unselect 'Correct spelling automatically'

turn off spaces key shortcuts

System Preferences –> Keyboard –> Keyboard Shortcuts –> unselect C+{<-,->}

homebrew

Note that El Capitan introduced System Integrity Protection (SIP), which may need to be temporarily disabled during homebrew installation. See https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/El_Capitan_and_Homebrew.md

If it becomes necessary to fix permissions:

packages installed using homebrew

homebrew cask

Command line installer for desktop applications. See https://caskroom.github.io

Install some applications

homebrew API token

Apparently lots of requests to GutHub via homebrew can hit a rate limit. There's a higher limit if you create an API token. See https://gist.github.com/christopheranderton/8644743

Here's the url for the token creation dialog:

Mac

Make sure that all 'scopes' are unchecked. Once you generate the token, add to your shell profile:

Homebrew

zsh

Install zsh with Homebrew above

Change shell to zsh

zsh init files are in Dropbox/zsh

ssh

After installing homebrew's openssh on El Capitan, ssh-agent no longerseemed to work (in the sense that after using ssh-add to cache apassphrase, I still got a system prompt when trying to ssh). Thisseemed to be fixed by the instructions I found at the url below (myversion is functionally the same but uses PlistBuddy to edit theplist):

update /System/Library/LaunchAgents/org.openbsd.ssh-agent.plist

This should change the original value of ProgramArguments:

to

Now restart the service

Capitan

create $ZSH_INITDIR/ssh-ask-keychain (called from start_ssh_agent.zsh)

create $ZSH_INITDIR/start_ssh_agent.zsh

(either as a file sourced from .zshrc, or as a code block in a login script)

git

emacs

Install emacs24 binary from http://emacsformacosx.com/

Check out my .emacs.d

python

Use homebrew - seehttps://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md

Run brew info python for required and optional dependencies(installed above).

Install some python packages using homebrew - these are time consuming to install otherwise.

Install some other packages to the system using pip.

For elpy:

ansible

Others

Homebrew Failed El Capitan

R

Really doubling down on homebrew this time around:

mail

sshfs

Provided by the project http://osxfuse.github.io/ - the links beloware for binaries provided as installers.

wkhtmltopdf

Now create an alias:

Comments

Please enable JavaScript to view the comments powered by Disqus.

NTFS support in OS X is disappointing. You plug in a USB flash drive from a co-worker who uses Windows to simply copy over a file, only to realize that you can't actually write to NTFS-formatted drives on Mac out of the box.

That's kind of lame, to be honest. It's 2016, Apple, wake up! People who work together in the same office, on different operating systems, should be able to exchange files via USB flash drive with ease, without having to worry about formatting their drives with a cross-platform filesystem, like exFAT.

Solutions

There are a few ways to enable NTFS write support on OS X.

  1. Using the built-in NTFS drivers - Writing to NTFS drives is a functionality that's been built into OS X for some time. However, it's disabled by default for NTFS volumes, and for good reason. It's extremely buggy and corrupts entire volumes in certain situations. I tried copying 4GB worth of data to an NTFS volume this way, and the transfer just failed half-way, rendering the disk inaccessible and my computer unbootable, until I manually disconnected the SATA cable from the hard drive. Luckily, hot-plugging the drive to Windows 7 and running dskchk fixed the issue, but other people reported losing all of their data because of these faulty drivers. Therefore, I strongly advise against this method.
  2. Purchasing Tuxera/Paragon NTFS for Mac - A viable option, albeit quite expensive (Tuxera - $26.50, Paragon - $19.95), at least for something that should already be included with the OS. I shouldn't have to pay good money to be able to write to an NTFS volume. There has to be another way.
  3. Downloading and installing OSXFUSE and NTFS-3G - The winning option. NTFS-3G is an NTFS read/write driver that is free and open-source, and there don't seem to be any corruption issues arising from using it.
Installing OSXFUSE

So, what is OSXFUSE anyway?

FUSE for OS X allows you to extend OS X's native file handling capabilities via third-party file systems. As a user, installing the OSXFUSE software package will let you use any third-party file system written atop OSXFUSE or MacFUSE, if you choose to install the MacFUSE compatibility layer.

So basically, it's a way for developers to extend OS X's native file handling APIs to other file systems.

It's required by NTFS-3G, so let's go ahead and install the latest OSXFUSE (3.x.x) from here:
https://github.com/osxfuse/osxfuse/releases

Download the latest osxfuse-3.x.x.dmg attachment, mount it, and install it, as with any other .dmg.

Note: Make sure to select the MacFUSE Compatibility Layer in the installation options. NTFS-3G depends on it.

Installing NTFS-3G

Once that's done, we can go ahead and install NTFS-3G. But not so fast, we need Homebrew for that.

Verify that you have Homebrew installed by running:

If you don't, install it using this one-liner:

Homebrew El Capitan Free

In any case, go ahead and update the Homebrew formula:

Next, let's finally install NTFS-3G via Homebrew:

Replacing Mount_NTFS

To get NTFS-3G to work, we need to replace the built-in /sbin/mount_ntfs binary, which is linked to Apple's NTFS driver, with NTFS-3G's mount_ntfs.

Homebrew El Capitan

This was a pretty easy thing to do before OS X 10.11 El Capitan, but due to System Integrity Protection, it is now slightly harder.

System Integrity Protection is a security technology in OS X El Capitan that's designed to help prevent potentially malicious software from modifying protected files and folders on your Mac.

It restricts the root account and limits the actions that the root user can perform on protected parts of OS X.

Therefore, we can't simply swap out the binary by using sudo and running ln. That is, not until we disable System Integrity Protection.

Disabling SIP

Reboot your Mac, and hold Cmd + R to enter Recovery mode. Within the Terminal, enter the following command to disable SIP and reboot back into OS X:

Replacing the Binary Link

Boot into OS X, and open a Terminal window. Within the Terminal, enter the following commands to swap out the link to the native mount_ntfs binary with a link to NTFS-3G's mount_ntfs binary:

Re-enabling SIP

Reboot into Recovery mode again, this time, to re-enable SIP. Within the Terminal, enter the following command to enable SIP and reboot back into OS X:

That's It!

NTFS-3G will automatically mount your NTFS volumes in read-and-write mode once you reboot back into OS X. Go ahead and copy some files over to an NTFS volume to make sure it works. Well done!