How to repair Homebrew after OS X upgrade

I was getting the following error when running brew after the latest upgrade to OS X (El Capitan).

 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory

I couldn't even run brew update - arg.

This is what I did to correct the issue - git to the rescue!

cd /usr/local/Library

git pull origin master

git pull will throw an error if you have changes in the directory (/usr/local/Library). If so, you'll have to fetch the master branch and perform a hard reset.

git fetch --all

git reset --hard origin/master

You should be able to now use brew again - hurrah!

Note: in the event you installed Homebrew as a non-root user, you'll need to cd to /Users/non-root-user-rname/homebrew/Library instead of /usr/local/Library.

How to setup / use Mac to Mac remote desktop connection

On the machine you want to remotely connect to:

  • Go to System Preferences.
  • Click on Sharing folder.
  • If necessary, click the lock at bottom left and enter your password to make changes.
  • Put a check mark next to Screen Sharing on the left.
  • OPTIONAL: Click the Computer Settings… button on the right.
  • Put a check mark next to “VNC viewers may control screen with password:” and set a password to use for screen sharing.
  • Click OK.
  • To secure logins to only your account, make sure it’s set to “Allow access for: Only these users.” Click the plus button at the bottom of the list.
  • Select your name (or the name of the user account you use) from the list and click the Select button. If you would like to enable file sharing as well, put a check mark next to File Sharing on  the left.

On the machine you’ll be connecting from:

  • Go to Finder.
  • Select Connect to Server from the Go menu.
  • In the Server Address field type in the IP address of your remote computer preceded by “vnc:”.
  • Click the Connect button and it will open the remote desktop in a new window. You will have control over the keyboard and mouse as if you were sitting down at that computer.
  • When you’re done, close that window.
  • To access files and folders on the remote computer, select Go to Folder from the Go menu.
  • Type in the IP address of the computer you wish to connect to preceded with “afp:” as it appeared in File Sharing above.
  • Click the Go button and the folders you have access to on the remote computer will open in a new Finder window.
  • When you’re done, close that window.

 

How to restart only the graphical side of OS X via Terminal

I have a variety of mac minis that I use to display stats and system status. Sometimes the Safari browser that is displaying the stats graphs on those remote mac minis locks up / runs out of memory. This makes using Remote Desktop to restart the remote Safari session impossible as I can't login to the machine. Rather than walk over to force a reboot I can ssh into the box and restart the WindowsServer (WindowsServer is the graphical user interface manager and is typically the thing that is borked). 

To resolve this issue I ssh into the machine via Terminal and then run the following command:

sudo killall -HUP WindowServer

Any open applications will be forced to close so use the command with caution.

How to unpack a .deb file on Mac OS X without installing it

If you use Xcode, a utility called ar is installed. You can run the following command:

ar -x path/to/filename.deb

If you don't use Xcode, you could also install ar using Homebrew and run the same command.

Alternatively, you could use Homebrew to install the dpkg utility which has many more options to work against .deb files.

dpkg -c path/to/filename.deb