Skip to content

Latest commit

 

History

History
142 lines (120 loc) · 7.78 KB

SETUP.md

File metadata and controls

142 lines (120 loc) · 7.78 KB

Setup

This document describes how to set up your workstation to develop for Code.org.

You can do Code.org development using OSX, Ubuntu, or Windows (running Ubuntu in a VM). Setup for Windows is more complicated and relatively few developers use it. Make sure you follow the instructions for your platform in the subsections below.

Overview

  1. Install OS-specific prerequisites
  2. git clone https://github.com/code-dot-org/code-dot-org.git
  3. gem install bundler -v 1.10.6
  4. rbenv rehash
  5. cd code-dot-org
  6. bundle install
  7. rake install
  8. (Optional) Enable JavaScript builds
  9. rake build

OS-specific prerequisites

OS X Mavericks / Yosemite / El Capitan

  1. Install Homebrew: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. Run brew install https://raw.github.com/quantiverge/homebrew-binary/pdftk/pdftk.rb enscript gs mysql nvm imagemagick rbenv ruby-build coreutils sqlite phantomjs
  3. (El Capitan) If you see permissions issues, run sudo chown -R $(whoami):admin /usr/local/. More info here.
  4. If it complains about an old version of <package>, run brew unlink <package> and run brew install <package> again
  5. Set up MySQL
  6. Have launchd start mysql at login: ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
  7. Start mysql now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
  8. Set up rbenv
  9. Run rbenv init
  10. Add the following to ~/.bash_profile or your desired shell: eval "$(rbenv init -)". More info here.
  11. Pick up those changes: source ~/.bash_profile
  12. Install Ruby 2.2.3
  13. rbenv install 2.2.3
  14. Set the global version of Ruby: rbenv global 2.2.3
  15. Install shims for all Ruby executables: rbenv rehash. More info here.
  16. Set up nvm
  17. Create nvm's working directory if it doesnt exist: mkdir ~/.nvm
  18. Add the following to ~/.bash_profile or your desired shell configuration file: export NVM_DIR=~/.nvm . $(brew --prefix nvm)/nvm.sh
  19. Pick up those changes: source ~/.bash_profile
  20. Install Node 0.12.15
  21. These steps are necessary because of problems with the newest versions of node. We want to be on node 0.12.15 and npm 2.15.1.
  22. nvm install 0.12.15 this command should make this version the default version and print something like: Creating default alias: default -> 0.12.15 (-> v0.12.15)
  23. (You can reinstall with your updated version after you clone the repository if necessary) Reinstall node_modules cd apps; rm -rf node_modules && npm install; cd ..
  24. (El Capitan) Ensure that openssl is linked: brew link --force openssl
  25. Check that you have the correct versions of everything:
  26. Open a new Terminal window
  27. ruby --version # --> ruby 2.2.3
  28. nvm ls # --> v0.12.15
  29. node --version # --> v0.12.15
  30. npm --version # --> 2.15.1

Ubuntu 14.04

  1. sudo apt-get update
  2. sudo apt-get install -y git mysql-server mysql-client libmysqlclient-dev libxslt1-dev libssl-dev zlib1g-dev imagemagick libmagickcore-dev libmagickwand-dev openjdk-7-jre-headless libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev curl pdftk enscript libsqlite3-dev phantomjs build-essential
  • Hit enter and select default options for any configuration popups, leaving mysql passwords blank
  1. Upgrade npm to 2.0. If npm -v says less than 2.0 then
  • sudo add-apt-repository ppa:chris-lea/node.js
  • sudo apt-get update
  • sudo apt-get install nodejs
  1. Either A. Install Ruby 2.2 from OS packages; B. Setup rbenv; or C. Setup rvm
    • A. OS packages (from the Brightbox Ubuntu PPA):
      • sudo apt-get install software-properties-common
      • sudo apt-add-repository ppa:brightbox/ruby-ng
      • sudo apt-get update
      • sudo apt-get install ruby2.2 ruby2.2-dev
    • B. rbenv: (instructions)
      1. Install rbenv and ruby-build
      2. rbenv install 2.2.3
      3. rbenv global 2.2.3
      4. rbenv rehash
    • C. rvm. A few folks have had more luck with rvm vs rbenv on linux.
      1. Install rvm from https://rvm.io/
      2. rvm install 2.2.3
      3. rvm use 2.2.3 --default
  2. Install Node.js 0.12.15 and npm 2.15.1
  3. Option A - nvm 1. curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
    • After completion, close your current terminal window and open a new one. 1. nvm install (this will install the version defined in .nvmrc)
  4. Option B - nodesource repository 1. curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash - 1. sudo apt-get install -y nodejs
  5. Option C - Manual install 1. Nodejs.org
  6. Check that you have the correct versions of everything:
  7. open a new Terminal window
  8. ruby --version # --> ruby 2.2.3
  9. node --version # --> v0.12.15
  10. npm --version # --> 2.15.1

Windows note: use an Ubuntu VM

Many Windows developers have found that setting up an Ubuntu virtual machine is less painful than getting Ruby and other prerequisites running on Windows.

  • Option A: Use VMWare Player and an Ubuntu 14.04 iso image
  • Option B: Use vagrant (install):
    1. First clone the code.org git repo to get the provided Vagrantfile (you will be able to skip step 1 of the common setup instructions): git clone https://github.com/code-dot-org/code-dot-org.git
    2. cd code-dot-org
    3. vagrant up
    4. vagrant ssh
    5. Goto step 2 of the common setup instructions
  • Option C: Use AWS EC2: launch Ubuntu 14.04 AMI

Enabling JavaScript builds

The default dashboard install uses a static build of JS, but if you want to make modifications to these you'll want to enable local builds of the JavaScript packages. You'll need to do this once:

  1. (OS X) Install the Java 8 JDK

  2. Edit locals.yml and enable the following options:

    # code-dot-org/locals.yml
    
    # These enable the local apps build
    build_apps: true
    use_my_apps: true
    
    # This enables the local blockly-core build
    build_blockly_core: true
    
  3. Run rake package for the changes to take effect.

This configures dashboard to rebuild apps/blockly-core whenever you run rake build and to use the versions that you built yourself. See the documentation in those directories for faster ways to build and iterate.

If waiting around for javascript builds is making you sad, consider sending build time logs to New Relic so we can track the slowness. You can do this by copying our license key from the New Relic account page and pasting it into locals.yml:

new_relic_license_key: <license key here>

More Information

Please also see our other documentation, including our:

Wondering where to start? See our contribution guidelines for more information on helping us out.