Installation Guide
1. Text editor
Install a programmer’s text editor such as Visual Studio Code or Atom.
2. Ruby
Install the Ruby programming language
- On Windows, install Ruby 2.1 using RubyInstaller
- In the installer, select the checkbox “Add Ruby executables to your PATH”
- Ruby 2.2 is not yet supported by dm-sqlite-adapter (because do_sqlite3-0.10.16 does not include the binary for it), so if you are using Windows you must use Ruby 2.1 or earlier
- On OS X, install Homebrew by following the instructions on its homepage, and then, in your terminal, run the command
brew install ruby
, and after installing Ruby, be sure to restart the terminal app.- When it is asking for your password, write the password you use for signing in to your computer. Note! Typing your password will not show up as any characters in the prompt.
- On other operating systems, see Installing Ruby
3. SQLite
- On Windows, download the sqlite-dll package and copy the
sqlite3.dll
file to Ruby’s bin folder (C:\Ruby21\bin
)
4. DB Browser for SQLite
- Install DB Browser for SQLite
5. Ruby libraries
- Run the following command in your terminal (known as the Command Prompt on Windows) to install some Ruby libraries which we’ll use in this tutorial:
gem install sinatra:1.4.7 sinatra-contrib:1.4.7 data_mapper dm-sqlite-adapter erubis --no-ri --no-rdoc
- While the computer is in the middle of performing the command, a cursor will blink on an empty line. When the command is completed, there will be stuff in front of the blinking cursor.
- On OS X and Linux, if the command fails complaining about permissions, add the
sudo
word to the beginning of the command and try again.
6. Test that it all works
- Save this test.rb file in a folder you can locate (instructions for getting the full path for a folder: Windows and Mac/Linux), run the command
ruby test.rb
in your terminal, either by typing it or copy-pasting it in. - If the terminal says “
Database OK
” and you can visit http://localhost:4567/ with your web browser (e.g. Firefox, Safari, or similar) and if it says “Web server OK
”, then you’re all done!
Workarounds to some problems
getaddrinfo: The requested name is valid, but no data of the requested type was found. (SocketError)
If you get this error when running ruby test.rb
, it means that the web server is failing to listen on the 0.0.0.0
host, your computer’s public network interface. A workaround is to make it listen only private connections.
Try running ruby test.rb -o 127.0.0.1
and if it works, you will need to add the -o 127.0.0.1
option also when running your application during the rest of this guide.