Setup recipe for Rails Girls

Cooking time: 5min active / 15-30min passive

To build apps and other things with Ruby on Rails, we need to setup some software and the developer environment for your computer.

Follow the instructions for your operating system. If you run into any problems, don’t panic. Inform us at the event and we can solve it together.


Setup for macOS

1. Let’s check the version of the operating system.

Click the Apple menu and choose About this Mac.

Apple menu

2. In the window you will find the version of your operating system.

If your version number starts with 10.6, 10.7, 10.8, 10.9, 10.10, 10.11 or higher this guide is for you. If it’s something else, we can setup your machine at the event.

About this Mac dialog

3a. If your OS X / macOS version is 10.9 or higher:

If your version number starts with 10.9, 10.10, 10.11 or higher, follow these steps. We are installing homebrew and rbenv.

3a1. Install Command line tools on terminal:

xcode-select --install

3a2. Install Homebrew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3a3. Install rbenv:

brew update
brew install rbenv
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile

3a4. Build Ruby with rbenv:

You can find the newest version of Ruby with the command “rbenv install -l”.

rbenv install 2.6.4

If you got “OpenSSL::SSL::SSLError: … : certificate verify failed” error, try it this way.

brew install curl-ca-bundle
cp /usr/local/opt/curl-ca-bundle/share/ca-bundle.crt `ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE'`

3a5. Set default Ruby:

rbenv global 2.6.4

3a6. Install rails:

gem install rails --no-document

3b. If your OS X version is 10.6, 10.7, or 10.8:

Download the RailsInstaller for your version of OS X:

Double click the downloaded file and it will unpack it into the current directory. Double click the the newly unpacked ‘RailsInstaller-1.0.4-osx-10.7.app’ or ‘RailsInstaller-1.0.4-osx-10.6.app’ and follow the instructions. It will open a README file with ‘Rails Installer OS X’ at the top. Please ignore the instructions in this file.

If the Rails version wasn’t the latest, you could update it using a following command on terminal.

gem update rails --no-document

4. Install yarn:

brew install yarn

If you need more information than the following to install yarn, please check yarn’s installation docs.

5. Install a text editor to edit code files

For the workshop we recommend the text editor Atom.

If you are using Mac OS X 10.7 or older versions, you can use another editor Sublime Text 2. Just to make sure that you’re not mixing up using your terminal or text-editor: change the theme of your Sublime text-editor, choosing one of the following: “iPlastic”, “Slush & Poppies”, or “Zenburnesque”.

5. Check the environment

Check that everything is working by running the application generator command.

rails -v

Should output Rails 6.0.0 (or a higher version).

rails new myapp
cd myapp
rails server

Go to http://localhost:3000 in your browser, and you should see the ‘Yay! You’re on Rails!’ page.

Now you should have a working Ruby on Rails programming setup. Congrats!

Coach: We recommend to verify by using the scaffold command and inputting data with the generated page with coaches to ensure everything is working. Also: remove the test app myapp to make super sure no-one is working in the wrong folder, following the steps of the workshop.


Setup for Windows

To install Rails for Windows we’ll need to install Ruby and several supporting tools such as Git, Node.js and SQLite. Follow the steps below in order to install these tools on your computer. When you’re done with these steps you will have a Rails app running on your computer.

During these steps we’ll ask you to open and close the Windows Command Prompt every now and then. This can be either the “Command Prompt” or “Powershell” app. We ask you to close and re-open it, because when the Command Prompt starts it loads in the environment. When we install a new app, the environment does not get automatically updated in the Command Prompt. To test if the installation was successful we need to restart the Command Prompt and load the new environment.

1. Install Ruby

2. Install Git

3. Install Node.js

node --version

3a. Install yarn

yarn --version

4. Install SQLite

sqlite3 --version

5. Install Rails

gem install rails bundler --no-document
rails --version

If you run into any problems during this step, check the Possible errors section for possible solutions.

6. Install a text editor to edit code files

For the workshop we recommend the text editor Atom.

If you are using Windows Vista or older versions, you can use another editor Sublime Text 2. Just to make sure that you’re not mixing up using your command prompt or text-editor: change the theme of your Sublime text-editor, choosing one of the following: “iPlastic”, “Slush & Poppies”, or “Zenburnesque”.

7. Check the environment

Check that everything is working by running the application generator command.

rails new myapp
cd myapp
rails server

Go to http://localhost:3000 in your browser, and you should see the “Yay! You’re on Rails!” page.

Now you should have a working Ruby on Rails programming setup. Congrats!

If you run into any problems during this step, check the Possible errors section for solutions.

Coach: We recommend to verify by using the scaffold command and inputting data with the generated page with coaches to ensure everything is working. Also: remove the test app myapp to make super sure no-one is working in the wrong folder, following the steps of the workshop.


Setup for Linux

To install the Ruby on Rails development environment you just need to copy the lines below for your Linux distribution (Ubuntu or Fedora), paste it in the Terminal and press Enter. Enjoy the text flying on the screen; it will take quite some time. Grabbing a refreshing drink before starting is encouraged.

1. Install yarn

If you need more information than the following to install yarn, please check yarn’s installation docs.

For Ubuntu:

sudo apt-get install curl
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn

For Fedora:

curl -sL https://rpm.nodesource.com/setup_12.x | bash -
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn

2. Install Rails

For Ubuntu:

bash < <(curl -sL https://raw.github.com/railsgirls/installation-scripts/master/rails-install-ubuntu.sh)

If you are going to use RVM installations with gnome-terminal, you’ll probably need to change it’s default options before you can see and use the right Ruby and Rails versions. Find out how: RVM documentation.

For Fedora:

bash < <(curl -sL https://raw.github.com/railsgirls/installation-scripts/master/rails-install-fedora.sh)

Make sure that all works well by running the application generator command.

rails new myapp

4. Install a text editor to edit code files

For the workshop we recommend the text editor Sublime Text.

5. Check the environment

Check that everything is working by running the application generator command.

rails new myapp
cd myapp
rails server

Go to http://localhost:3000 in your browser, and you should see the ‘Yay! You’re on Rails!’ page.

Now you should have a working Ruby on Rails programming setup. Congrats!

Coach: We recommend to verify by using the scaffold command and inputting data with the generated page with coaches to ensure everything is working. Also: remove the test app myapp to make super sure no-one is working in the wrong folder, following the steps of the workshop.


Virtual Machine

Instead of installing all tools on your machine, you can also set up a development environment in a Virtual Machine. Please find all the details here.


Using a Cloud Service

Instead of installing Ruby on Rails and an editor on your computer, you can use a webservice for development. All you need is a browser and an internet connection. This guide explains how to get started with codenvy.io. If you’re using a different service, they may use a different wording, but the process is usually pretty similar.

1. Create an account

Go to codenvy.io and signup for free. You will need to confirm your email and then fill in your details.

2. Setup a workspace for Ruby on Rails

The Ruby on Rails Workspace has all the software we need for the workshop already preinstalled. To create a workspace, log into codenvy.io and click on ‘Dashboard’. If no workspace has been created yet, the ‘New Workspace’ view is displayed.

In the ‘New Workspace’ view, a few settings have to be made.

3. Find and restart your workspace

4. Coding with your project

Possible errors during installation

Gem::RemoteFetcher error

If you get this error when running rails new railsgirls or gem update rails:

Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read
server certificate B: certificate verify failed (https://rubygems.org/gems/i18n-0.6.11.gem)

This means you have an older version of Rubygems and will need to update it manually first verify your Rubygems version

gem -v

If it is lower than 2.6.5 you will need to manually update it:

First download the ruby-gems-update gem. Move the file to c:\\rubygems-update-2.6.11.gem then run:

gem install --local c:\\rubygems-update-2.6.11.gem
update_rubygems --no-document
gem uninstall rubygems-update -x

Check your version of rubygems

gem -v

Make sure it is equal or higher than 2.6.11. Re-run the command that was failing previously.

If you are still running into problems you can always find the latest version of rubygems online at rubygems.org. If you click on GEM you will get the latest version.

During bundle install

The Gem::RemoteFetcher::FetchError: SSL_connect can also occur during the bundle install stage when creating a new rails app.

The error will make mention of bit.ly/ruby-ssl. What is relevant for Windows users at this point is this GitHub gist. The described manual way has proven to be successful to solve the bundle install error.

‘x64_mingw’ is not a valid platform Error

Sometimes you get the following error when running rails server: 'x64_mingw' is not a valid platform If you experience this error after using the RailsInstaller you have to do a small edit to the file Gemfile:

Look at the bottom of the file. You will probably see something like this as one of the last lines in the file: gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]. If you have this line with :x64_mingw, then please delete the :x64_mingw part. In the end it should just say: 'tzinfo-data', platforms: [:mingw, :mswin]

After you did that, please use your Command Prompt again and type bundle update.

The sqlite3 gem failed to install

When running rails new myapp the sqlite3 gem may fail to install. When this happens, first close the Windows Command Prompt app. Then re-open the Windows Command Prompt.

Next, install the sqlite3 gem separately from the rails gem by running the following command:

gem install sqlite3

If this succeeds, remove the myapp directory the rails installer created and return to the installation instructions, to run rails new myapp again.