Skip to content

Instantly share code, notes, and snippets.

@agilous
Created October 4, 2011 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agilous/1261571 to your computer and use it in GitHub Desktop.
Save agilous/1261571 to your computer and use it in GitHub Desktop.
Ubuntu 11.10 Ruby Development Environment

Motivation:

This system is intended to be used by American high school students with little or no programming experience and ZERO Linux system administration experience. A seasoned developer will find this setup too simplistic since many of the tools that a proficient Ruby developer relies on but which might confuse a novice Rubyist have been omitted.

Here are some pain points encountered when novice developers where initiated using a “typical” Linux-based development system:

  • Explaining the need for Bundler & RVM/rb-env drastically increased the learning curve.
  • Editors like emacs and vi were too esoteric for novice developers.
  • Choosing Heroku & PostgreSQL permitted us to simply “gloss over” the deployment process.
#!/bin/bash
# Update Ubuntu package information and install the minimum require software.
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y install build-essential curl git-core openssh-server
sudo apt-get -y install sqlite3 libsqlite3-dev postgresql postgresql-server-dev-8.4
# These are needed by the Redcar editor:
sudo apt-get -y install openjdk-7-jre
wget -O xulrunner.deb http://launchpadlibrarian.net/70321329/xulrunner-1.9.2_1.9.2.17%2Bbuild3%2Bnobinonly-0ubuntu1_amd64.deb
sudo dpkg -i xulrunner.deb
## These need to be installed before ruby.
sudo apt-get -y install libssl-dev libreadline6-dev libxml2-dev zlib1g zlib1g-dev libxss1
sudo apt-get -y install ruby1.9.1 ruby1.9.1-dev libyaml-dev
# Install Rubygems locally
mkdir ~/gems ~/src
cd ~/src
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.17.tgz
tar -xzvf rubygems-1.8.17.tgz
cd rubygems-1.8.17
ruby setup.rb --prefix=~/
ln -s ~/bin/gem1.9.1 ~/bin/gem
# Set environment variable in ~/.bashrc, add these lines at the bottom of the file:
export GEM_HOME=~/gems
export PATH=$HOME/bin:$GEM_HOME/bin:$PATH
# Then source the changed ~/.bashrc file:
. ~/.bashrc
# Install Rails
gem install rails
# Install Redcar
# ? gem install psych
gem install redcar
## Per: https://redcar.lighthouseapp.com/projects/25090/tickets/585-redcar-013-crashes-at-startup-on-ubuntu-1110
## Edit ~/gems/specifications/redcar-0.13.gemspec and replace this line:
## s.date = %q{2012-01-21 00:00:00.000000000Z}
## With this:
## s.date = %q{2012-01-21}
redcar install
# Create demo app using the Postgresql database and delaying the call to bundle install
rails new demo --database=postgresql --skip-bundle
cd demo # cd to the newly created Rails project root
# Add 'therubyracer' (a JavaScript runtime environment) to the Gemfile after: gem 'pg'
ruby -pi -e "puts %{gem 'therubyracer', :require => 'v8'} if $.==9" Gemfile
bundle install --path vendor # run the `bundle install` that we delayed earlier
bundle exec rails server # and start a local server
# open your browser and visit:
http://localhost:3000/
# or from another machine:
http://{IP-address-of-this-machine}:3000/

Next steps:

… (yes, this is the start of a syllabus or at least an agenda for Wednesday)

  1. git
    1. edit config/database.yml
      • discuss trade-off between SQLite3 and PostgreSQL for local development
    2. create development and testing databases
      sudo su – postgres
      createuser -s web-apps -P # Enter any password you choose but be sure to remember it!
      createdb -O web-apps demo_development
      createdb -O web-apps demo_test
      exit
    3. restart server
  2. create models, migrations, controllers, etc.
  3. Testing!
    • mini::spec and mini::unit
    • RSpec and BDD v. TDD
  4. Heroku
  5. Capistrano
  6. NewRelic RPM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment