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
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:hooks
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 from the above command 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
- If it complains about
- 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
- Have
- 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
- Run
- 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.0
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
- Prevent future problems related to the
Too many open files
error:- Add the following to
~/.bash_profile
or your desired shell configuration file:ulimit -n 8192
- close and reopen your current terminal window
- make sure that
ulimit -n
returns 8192
- Add the following to
- install the Xcode Command Line Tools:
xcode-select --install
Ubuntu 17.04 (Download iso) Note: Virtual Machine Users should check the Windows Note below before starting
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-9-jre-headless libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev curl pdftk enscript libsqlite3-dev phantomjs build-essential redis-server rbenv ruby-build npm ruby2.3-dev
- Hit enter and select default options for any configuration popups, leaving mysql passwords blank
- Install Node and Nodejs
- Type
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
- And then
sudo apt-get install -y nodejs
- Type
- Install Ruby 2.2.3 with rbenv
rbenv install 2.2.3
rbenv global 2.2.3
rbenv rehash
- Install yarn
- First, type
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
- Then
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
- And lastly,
sudo apt-get update && sudo apt-get install yarn=0.23.2-1
- First, type
- Finally, configure your mysql to allow for a proper installation. You may run into errors if you did not leave mysql passwords blank
- Type
echo "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';" | sudo mysql
- Type
- Read the following notes, then go back up to the overview and run the commands there.
- If, for any reason, you are forced to interrupt the
rake install
command before it completes, cd into dashboard and runbundle exec rake db:drop
before tryingrake install
again rake install
must always be called from the local project's root directory, or it won't work.- Finally, don't worry if your versions don't match the versions in the overview if you're following this method; the installation should still work properly regardless
- If, for any reason, you are forced to interrupt the
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 or Virtual Box and an Ubuntu 17.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):
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
If you continue to have issues with rmagick, after changing your imagemagick version, you may need to uninstall/reinstall the gemgem uninstall rmagick
gem install rmagick -v 2.15.4