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.
- Install OS-specific prerequisites
git clone https://github.com/code-dot-org/code-dot-org.git
gem install bundler -v 1.10.6
rbenv rehash
cd code-dot-org
bundle install
(Problems with rmagick? See tips below.) (OS X: when runningbundle install
, you may need to also runxcode-select --install
. See stackoverflow)rake install
- (Optional) Enable JavaScript builds
rake build
-
Install Homebrew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-
Install Redis:
brew install redis
-
Run
brew install https://raw.github.com/quantiverge/homebrew-binary/pdftk/pdftk.rb enscript gs mysql nvm imagemagick rbenv ruby-build coreutils sqlite phantomjs
-
If it complains about
Formula.sha1
is disabled, removing https://raw.github.com/quantiverge/homebrew-binary/pdftk/pdftk.rb seems to not have serious side effects (it will causePDFMergerTest
to fail). -
If it complains about an old version of
<package>
, runbrew unlink <package>
and runbrew install <package>
again -
Set up MySQL
-
Have
launchd
start mysql at login:ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
-
Start mysql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
-
Set up rbenv
-
Run
rbenv init
-
Add the following to
~/.bash_profile
or your desired shell:eval "$(rbenv init -)"
. More info here. -
Pick up those changes:
source ~/.bash_profile
-
Install Ruby 2.2.3
-
rbenv install 2.2.3
-
Set the global version of Ruby:
rbenv global 2.2.3
-
Install shims for all Ruby executables:
rbenv rehash
. More info here. -
Set up nvm
-
Create nvm's working directory if it doesnt exist:
mkdir ~/.nvm
-
Add the following to
~/.bash_profile
or your desired shell configuration file:# Load nvm function into the shell export NVM_DIR=~/.nvm source $(brew --prefix nvm)/nvm.sh
-
Pick up those changes:
source ~/.bash_profile
-
Install Node, npm, and yarn
-
nvm install 6.9.0 && nvm alias default 6.9
this command should make this version the default version and print something like:Creating default alias: default -> 6.9.0 (-> v6.9.0)
-
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.23.2
-
(You can reinstall with your updated version after you clone the repository if necessary) Reinstall node_modules
cd apps; yarn; cd ..
-
(El Capitan) Ensure that openssl is linked:
brew link --force openssl
sudo apt-get update
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 redis-server
- Hit enter and select default options for any configuration popups, leaving mysql passwords blank
- Upgrade npm to 3.10.8 If
npm -v
says less than 3.10.8 then
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
-
Either A. Install Ruby 2.2 from OS packages; B. Setup
rbenv
; or C. Setuprvm
- 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)- Install
rbenv
andruby-build
rbenv install 2.2.3
rbenv global 2.2.3
rbenv rehash
- Install
- C.
rvm
. A few folks have had more luck with rvm vs rbenv on linux.- Install rvm from https://rvm.io/
rvm install 2.2.3
rvm use 2.2.3 --default
- A. OS packages (from the Brightbox Ubuntu PPA):
-
Install Node, npm, and yarn
-
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
)
- After completion, close your current terminal window and open a new one.
1.
-
Option B - nodesource repository 1.
curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash -
1.sudo apt-get install -y nodejs
-
Option C - Manual install 1. Nodejs.org
-
Finally, install yarn:
npm install -g [email protected]
-
When running
bundle install
, you may need to runbundle config build.nokogiri --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2
first so that nokogiri picks up the built in libxml2 library. See this stackoverflow answer.
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
- Maximum Disk Size should be set to 30.0 GB (the default is 20 GB and it is too small)
- Memory Settings for the VM should be 2 GB or higher (Right click the machine -> Settings -> "Memory for this virtual machine" )
- Option B: Use vagrant (install):
- 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
cd code-dot-org
vagrant up
vagrant ssh
- Goto step 2 of the common setup instructions
- 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):
- Option C: Use AWS EC2: launch Ubuntu 14.04 AMI
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:
-
(OS X) Install the Java 8 JDK
-
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
-
Run
rake package
for the changes to take effect.
This configures dashboard to rebuild apps whenever you run rake build
and to use the version that you built yourself. See the documentation in that directory 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>
Please also see our other documentation, including our:
Wondering where to start? See our contribution guidelines for more information on helping us out.
If rmagick doesn't install, check your version of imagemagick, and downgrade if >= 7
convert --version
brew install imagemagick@6
brew unlink imagemagick
brew link imagemagick@6 --force