Skip to content
This repository has been archived by the owner on Mar 9, 2019. It is now read-only.

Setting up your development environment

Chad Simmons edited this page Mar 11, 2015 · 34 revisions

Here is a basic walkthrough on how to set up your development on an ubuntu precise (12.04) 32bit machine. The basic RVM info was taken from the Rails Tutorial Book.

If you are going to be doing this in a VM, I recommend using vagrant. I have a box you can clone from https://github.com/jhenkens/vagrant-ruby-rvm that will do all of the package installation and RVM setup for you - all that needs to be done after is the postgres commands.

If you set up vagrant and want to use my box, issue the following commands, otherwise, skip to Basic package Requirements.

git clone https://github.com/jhenkens/vagrant-ruby-rvm OctopiVM
cd OctopiVM
vagrant up
vagrant ssh

To do remote debugging, follow: https://coderwall.com/p/fus7na

Basic package requirements

$ sudo apt-get update && sudo apt-get upgrade 
$ sudo apt-get install \
openjdk-7-jre ruby1.9.3 git-core curl nodejs postgresql-9.1 \
postgresql-server-dev-9.1 libxml2-dev

Postgresql setup

It is recommended that we use the same database for development as we will use for production. Postgresql is well regarded, and is the current plan for our database. If using Mac, follow the instructions here but replace the username 'blog' with octopi. For ubuntu 12.04, follow the steps below (hints were modified from a StackOverflow post):

Set up a user for your ubuntu login

$ sudo su postgres -c psql <<EOF
CREATE ROLE <username> SUPERUSER LOGIN;
\q
EOF

Change unix-socket based (local) logins to be trusting (don't check user auths)

$ sudo sed -i -e 's/^\(local\s*all\s*all\s*\)peer/\1trust/' /etc/postgresql/9.1/main/pg_hba.conf
$ sudo service postgresql restart

Create your personal db so we can login

$ createdb

Log in to postgres and create an octopi user and change some database encoding settings

You will have to enter the following commands, isolated here for copy/paste ease.

psql <<EOF
CREATE USER octopi CREATEDB;
update pg_database set datistemplate=false where datname='template1';
drop database Template1;
create database template1 with owner=postgres encoding='UTF-8'
  lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;
 
update pg_database set datistemplate=true where datname='template1';
EOF
$ psql
vagrant=# CREATE USER octopi CREATEDB;
CREATE ROLE
vagrant=# update pg_database set datistemplate=false where datname='template1';
UPDATE 1
vagrant=# drop database Template1;
DROP DATABASE
vagrant=# create database template1 with owner=postgres encoding='UTF-8'
vagrant-#   lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;
CREATE DATABASE
vagrant=#
vagrant=# update pg_database set datistemplate=true where datname='template1';
UPDATE 1
vagrant=# \q

RVM Setup

I have the project configured to use ruby 2.0.0 and use rvm to manage a gemset. If you use a different gemset manager, you can ignore this and try to get it running with your own manager. Remember, do not run the RVM setup as root - it should be a user-level install.

$ curl -sSL https://get.rvm.io | bash -s stable
$ source ~/.bash_profile

Right now, you should go through and edit your ~/.bash* and ~/.zsh* files if you desire, since rvm appends stuff to them.

Next we will install the requirements to build ruby, and then install ruby, and finally create a new gemset for us to use.

$ rvm requirements
$ rvm install 2.0.0

Now we need to do one more thing. Open ~/.bash_profile in terminal and add the following two lines:

source ~/.profile
source ~/.bashrc

This fixes an issue with RVM that happens when the terminal can't recognize RVM. Source

Now you can go ahead and clone octopi-webapp using whichever method you like best. When you cd into the octopi-webapp folder, you should be greeted with a message informing you it created a new gemset.

You will need to also load the submodules for the project, particularly if you want to work with LaPlaya. (See: http://git-scm.com/book/en/v2/Git-Tools-Submodules)

You can verify things are going well by the following:

$ rvm gemset list

gemsets for ruby-2.0.0-p451 (found in /home/vagrant/.rvm/gems/ruby-2.0.0-p451)
   (default)
   global
=> octopi-webapp

From this point, you should be able to install RubyMine via the website, open the octopi-webapp project, and have all the 'Tools | Bundler' options work just as if they were run in the command line.

Finish setup and get it all running

$ bundle install --without production
$ rake db:create
$ rake db:migrate
$ rails s

Now try and open localhost:3000 in your browser of choice.

Importing/exporting heroku db

https://devcenter.heroku.com/articles/heroku-postgres-import-export

Windows

PostgreSQL Bundler information for Windows

In order to get the pg gem to build on cygwin for windows you need to add the following command to your bash profile (or potentially just do it once before the first install). `export CONFIGURE_ARGS='with-pg-dir="/cygdrive/c/Program Files/PostgreSQL/9.3" with-pg-lib="/cygdrive/c/Program Files/PostgreSQL/9.3/lib"