Make Better Things



I like to make better things.

A short guide to Homebrew

What is Homebrew

Homebrew is a package management system for Mac OS X.

How to install Homebrew

Step 1) Homebrew has a dependency on Xcode and Xcode command line tools. So first install latest Xcode and command line tools by going Xcode -> Preference, Choose “Downloads” tab and click on “install the Command Line Tools”

Step 2) Run this command in Terminal to install Homebrew -

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"

Now let’s go over a few common tasks you will have with Homebrew.

brew doctor

If you are doing any system update like OS X update or Xcode update you can check Homebrew’s health using this command. Homebrew will tell you if there is any issue with it or generally how to fix that issue.

brew update

This will update your Homebrew formula list. Please note that this will not update all your installed package it will just update the version and availability of packages you could install. You should run this often to keep your formula list updated or whenever you install/upgrade something new.

brew upgrade

This will update your installed packages.

brew install [package name here]

This will install new packages for you i.e.

brew install mysql

brew list

This will list all the packages that are currently installed on your system.

brew info [package name here]

This will show you information about a installed package.

brew uninstall [package name here]

The will remove package you previously installed.

So that’s is pretty much everything about Homebrew.

Uninstall mysql server from mac os x

Run this to completely uninstall mysql server from your mac os x machine.

sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/MySQL*
vim /etc/hostconfig and removed the line MYSQLCOM=-YES-
rm -rf ~/Library/PreferencePanes/MySQL*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /var/db/receipts/com.mysql.*

Install Gitlabhq with Gitolite on Mac OS X server (Mountain Lion 10.8)

Recently I got a task of setting up a mac mini server (Mountain Lion) with gitlabhq (with gitolite). I tried for around 15 times and finally got succeed. Here are the steps which I followed to setup, hope it will help someone setting up mac server with gitlab.
Step 1 – Create a user “git”

Step 2 – Login into user “git”

Step 3 - Install xcode 4.5

Step 4 - Install command line tools in Xcode. (Xcode -> Preferences -> downloads -> install command line tools)

Step 5 - Install “rails installer” from rails installer.org (this will install many dependencies)

Step 6 - Download and Install mysql from here http://dev.mysql.com/downloads/mysql

Step 7 – Setup root password for mysql with this command

/usr/local/mysql/bin/mysqladmin -u root password NEW_PASSWORD_HERE

Step 8 – Install Homebrew on mac (needed to install few things)

$ ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"

After homebrew install run doctor -

$ brew doctor

Step 9 – Get ownership of /usr/local

$ sudo chown -R $(whoami) /usr/local

Step 10 – Install qt and icu4c with brew.

$ brew install qt
$ brew install icu4c
$ brew install redis

Step 11 – Enable ssh login in system preferences. System Preferences -> Sharing -> Enable remote login

Step 12 – Create a ssh key without a password

$ ssh-keygen -t rsa -N ''

Step 13 -Clone gitolite

$ git clone git://github.com/sitaramc/gitolite

Step 14 - Install gitolite

$ gitolite/install
use the following full path for gitolite:
/Users/git/gitolite/src/gitolite

Step 15 - Put this in .bashrc file and save in your home folder (~) -

export GIT_EXEC_PATH=/opt/local/libexec/git-core

Step 16 - Add this in .bash_profile and save in home folder (~)

$ sudo nano .bash_profile

and put this below text.

export PATH=/Users/git/gitolite/src:$PATH
export PATH=/Users/git/bin:$PATH
export PATH=/usr/local/mysql/bin:$PATH

Restart terminal

Step 17 -Setting up gitolite

Create link for .pub file

$ ln -s .ssh/id_rsa.pub GitlabAdmin.pub

setting up gitolite with ssh key

$ gitolite setup -pk ~/GitlabAdmin.pub

Step 18 - Making sure you can connect with ssh

$ ssh localhost

Step 19 - Confirm that you can connect to the gitolite-admin repository

$ git clone git@localhost:gitolite-admin

Step 20 - Cloning gitlabhq

$ git clone -b stable git://github.com/gitlabhq/gitlabhq.git

Step 21 - Running “bundle” on gitlabhq

$ cd gitlabhq
$ bundle

Step 22 - Bundle complete now -

$ bundle install --without development test

Step 23 - Configuriing gitlabhq

$ cp config/database.yml.example config/database.yml
$ cp config/gitlab.yml.example config/gitlab.yml

Step 24 - Now open this “config/gitlab.yml” and change “base_path” to “Users/git/repositories”

Step 25 - Open config/database.yml and change mysql password to your root account password. for production environment.

Step 26 - Setting up gitlabhq database in production environment -

 $ bundle exec rake db:setup RAILS_ENV=production
 

Got this error -

rake aborted!
dlopen(/usr/local/rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib
Referenced from: /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Reason: image not found – /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle

(See full trace by running task with –trace)

Got this fix on Stackoverflow -

$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

Running previous command again -

$ bundle exec rake db:setup RAILS_ENV=production

 $ bundle exec rake db:setup RAILS_ENV=production
 

Step 27 - Run redis

$ redis-server /usr/local/etc/redis.conf

Step 28 - Run this -

$ bundle exec rake db:setup RAILS_ENV=production
$ bundle exec rake db:seed_fu RAILS_ENV=production

Step 29 - Run -

</pre>
$ rails s -e production -p 8080
<pre>

Step 30 - open “localhost:8080″ in browser and login with -

login………admin@local.host
password……5iveL!fe

I hope you find this guide helpful. Comments are most welcome!