Skip to content
Sam Joseph edited this page Aug 22, 2016 · 13 revisions

Installation commands

To create a Cloud9 workspace to run LocalSupport:

  1. Fork the http://github.com/AgileVentures/LocalSupport repo (fork button at top right of github web interface)

  2. Create a workspace in Cloud9. Fill in the fields:

    • Workspace name: LocalSupport (or anything else that fits you)
    • Clone from Git or Mercurial URL: the url of your forked repository, e.g. https://github.com/your-git-id/LocalSupport.git
    • Choose a template: Select the Rails / Ruby icon
    • Click the Create workspace button

    If you get a message: ruby-2.x.y is not installed., see next section to install that version of ruby.

  3. Update package cache: sudo apt-get update

  4. Change branch for development: git checkout develop

  5. Install Qt webkit (source):

    sudo apt-get install qt5-default libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x

    (Note: for some reason, I could not get it to pass on the first try.)

  6. Configure the pre-installed postgreSQL. Check which version is installed with ls /etc/postgresql/. If the version is not 9.3, the sed commands must be edited to reflect the current version.

    # Change conf files to map your user to postgres user
    sudo sed -i 's/local[ ]*all[ ]*postgres[ ]*peer/local all postgres peer map=basic/' /etc/postgresql/9.3/main/pg_hba.conf
    sudo sed -i "$ a\basic $USER postgres" /etc/postgresql/9.3/main/pg_ident.conf
    # Start the service
    sudo service postgresql start
    # Make the default database template encoded in unicode
    psql -U postgres -c "update pg_database set encoding = 6, datcollate = 'C', datctype = 'C' where datname = 'template1';"
    sudo /etc/init.d/postgresql restart
  7. Install X virtual frame buffer

    sudo apt-get install xvfb

  8. Run bundle install to get the gems

(Note: If your connection breaks during the process retry until all gems are installed.)

  1. Run selenium install to download jars that this gem needs

  2. Get the javascript dependencies:

    sudo apt-get install npm
    npm install -g bower
    bower install
  3. (optional) Update the heroku tools : wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh

  4. Run the following to get the database set up and import seed data

    bundle exec rake db:create
    bundle exec rake db:migrate
    bundle exec rake db:setup

Note: You might encounter error with the creating the relevant schema. This is due to some configuration error with PostgreSql. Solution of interest can be found (1) here and (2) here. You should first drop the cluster as mentioned in (1) and then configure the user access privillages in pg_hba.conf and username mapping in pg_ident.conf. One way to successfully configure the line pg_hba.conf from

```
  # TYPE  DATABASE       USER            ADDRESS                 METHOD
  local   all             all                                     peer
```
to 

```
  # TYPE  DATABASE       USER            ADDRESS                 METHOD
  local   all             all                                     trust
```
and add a mapping in `pg_ident.conf`
```
# MAPNAME       SYSTEM-USERNAME                                         PG-USERNAME
basic           ubuntu(or the username of your C9 instance)             postgres
```
  1. Run locally with rails s -b $IP -p $PORT (in either a terminal or a run configuration window)

  2. Run the test (note the explicit call to xvfb when executing cucumber -- Cloud9 does not run an X-server)

    bundle exec rake db:migrate RAILS_ENV=test  
    bundle exec rake spec
    xvfb-run -a bundle exec cucumber

Installing another version of ruby in Cloud9

If the ruby version specified in the LocalSupport gemfile does not match one of the preinstalled version on Cloud9, the following message is outputted:

```
ruby-2.x.y is not installed.
To install do: 'rvm install ruby-2.x.y'
```

Execute the suggested command to install the proper version (the compilation of ruby may take some time). After completion, execute:

`gem install bundler`

You should also make that ruby version your default version, with the command:

rvm --default use 2.x.y