Skip to content
jpmckinney edited this page Sep 4, 2012 · 22 revisions

This guide has not been updated for the switch from MySQL to PostgreSQL.

Follow these instructions to get OpenlyLocal running locally on an OS X machine. These instructions have been tested with Xcode 4.1 on OS X Lion (10.7). We do not recommend using OS X in production.

Note: This guide is currently incomplete.

Homebrew

Homebrew is a package manager for OS X. It is preferred over alternatives such as MacPorts and Fink. If you haven't already installed Homebrew, run the command:

curl -fsSL https://raw.github.com/gist/323731 | /usr/bin/ruby

MySQL

You may encounter problems with the MySQL that ships with OS X. Use Homebrew's MySQL in that case:

brew install mysql
unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
mysql.server start
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/mysql/5.5.20/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

Check for any errors in Homebrew's output. You may need to run brew link cmake and run it again, for example. If you've already run bundle below using the default OS X MySQL, you will need to run gem install mysql again.

Redis

brew install redis
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/redis/2.4.11/homebrew.mxcl.redis.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

Ruby

RVM is the preferred way to install multiple Ruby versions on OS X. OpenlyLocal uses Ruby 1.8.7. The following commands assume you are using the Bash shell.

curl -s https://rvm.beginrescueend.com/install/rvm | bash

If you have Xcode 4.1, run the following line:

echo 'export CC=gcc-4.2' >> .bash_profile

Now, continue with:

echo [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >> .bash_profile
source .bash_profile
rvm install 1.8.7
rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system
rvm install 1.9.2
rvm use 1.9.2 --default

We set 1.9.2 as the default, since you are probably working on modern Ruby applications.

OpenlyLocal

Clone and bundle

git clone git@github.com:CountCulture/OpenlyLocal.git
rvm install ruby-1.8.7-p370
rvm use 1.8.7
cd OpenlyLocal
bundle

You may need to install SystemTimer separately, then run bundle again:

gem install SystemTimer -v '1.2.3'

If you experience any segmentation faults, try re-installing the gems mentioned in the stack trace separately, then run bundle again. For example, you may have to re-install the following (all of which build native extensions):

gem install curb -v '0.7.16'
gem install hpricot -v '0.8.4'
gem install json -v '1.6.3'
gem install nokogiri -v '1.4.7'
gem install yajl-ruby -v '0.7.9'

Configure

cp doc/examples/initializers/authentication_details.rb config/initializers/
cp doc/examples/initializers/geokit_config.rb config/initializers/
cp doc/examples/initializers/resque.rb config/initializers/
cp doc/examples/database.yml config/
cp doc/examples/resque.yml config/
cp doc/examples/smtp_gmail.yml config/

Add usernames and passwords to config/database.yml if necessary.

Create databases

bundle exec rake db:create:all

Having a dump of the production database is the easiest way to get started. You may load the schema with:

mysql -uroot openlylocal_development < doc/examples/structure.sql
mysql -uroot openlylocal_test < doc/examples/structure.sql

However, structure.sql doesn't track the schema. For now, you can run:

bundle exec rake db:schema:load

Download data

mkdir -p db/data/csv_data/postcodes
curl -O http://parlvid.mysociety.org:81/os/ONSPD_FEB_2012_UK_O.zip
unzip ONSPD_FEB_2012_UK_O.zip -d db/data/csv_data/postcodes

Run tests

Check that your setup is working by running the tests. The tests currently rely on some Rake tasks having run. Importing postcodes may take hours. You may prefer to only import an excerpt.

bundle exec cache_and_transfer_spending_data_summaries
bundle exec rake import_postcodes_from_csv
bundle exec rake test

Clone this wiki locally