After recently upgrading to El Capitan I found that sass had been removed.
No big deal, just reinstall it using

sudo gem install sass

What I wasn't expecting was the following error

Fetching: sass-3.4.18.gem (100%)
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/sass

I''m using sudo, effectively running as root so an operation not being permitted shouldn''t be an issue, right?
El Capitan has a new feature called System Integrity Protection, but it's more commonly known as rootless. There is still a root account but it cannot make modifications to some files and folders.
That's right, there are now files that root doesn't have permission to modify. Namely, it cannot edit the following directories in any way

  • /System
  • /bin
  • /sbin
  • /usr (except /usr/local)

Only an installer or updater signed by Apple can modify these locations.

This means that we cannot install a gem into the default location of /usr/bin
But thankfully we can specify the install directory as an argument to the gem install command

sudo gem install -n /usr/local/bin GEM_NAME_HERE

Installing sass into /usr/local/bin works correctly and it can be found by any other programs as /usr/local/bin in included in $PATH by default