Last updated: June 5, 2020
Tool | Recommended Version for CSE 3901 |
---|---|
Virtual Box | 6.x (tested 6.1) |
Ubuntu/Lubuntu | 20.04 LTS Desktop (64-bit) |
Ruby | 2.6.6 |
Rails | 6.0.3 |
To set up our virtual machine:
See the troubleshooting guide for solutions to some common problems.
Note: If you have an older home machine, try the Lubuntu distribution instead. The installation and configuration directions are virtually identical to Ubuntu. While Lubuntu is more responsive (especially on older hardware), its user interface is more primitive.
Download the appropriate Virtual Box platform package binary for your host machine's operating system from virtualbox.org.
Download Ubuntu Desktop (64-bit) ISO from ubuntu.com.
Note: Macs with M1 chips are not capable of emulating x86/64 architectures. To emulate Ubuntu on a Mac with an M1 chip, please use UTM. 1. Install Virtual Box on your home machine (accepting Oracle drivers if prompted). 1. Run Virtual Box. 1. Machine > New… then use the following values in the wizard:
**Name** | Something of your choosing (_e.g._, Ubuntu-20.04-64bit)
**Type** | Linux
**Version** | Ubuntu (64 bit)
**Memory size** | _at least_ 4 GB (recommend about 1/2 of your machine's installed RAM)
**Hard drive** | Create a virtual hard disk now
**Hard drive file type** | VDI
**Storage on physical hard drive** | Dynamically allocated
**File size** | 16 GB
The account you created in the previous step has administrator privileges which will allow you to do the customizations described below.
A terminal window can be openned using the keyboard shortcut Ctrl + Alt + T.
Open a terminal and update the distribution by typing the following commands (the "$" is the command prompt, don't type that! While "#" indicates a comment):
$ sudo apt update
$ sudo apt upgrade
$ sudo reboot
Install some useful linux tools:
$ sudo apt install git
Install a full-featured editor. Ubuntu comes with several basic editors, including nano, vim, and gedit. You can use whatever editor you like, but I recommend choosing one of vim, emacs, or sublime. The first two (vim and emacs) are old-school-cool, free, open-source, lightweight, and universally available on all flavors of unix. Knowing one of vim or emacs allows you to log in to some remote server and edit files there, even through a terminal ssh session. However, it will take some time to learn how to use either of these editors well. Sublime, on the other hand, has very little learning curve. It can be used for free while evaluating it (for an unlimited time), but if you decide to adopt it you should buy a license ($70).
Depending on which editor(s) you choose, do one (or more) of the following:
# for emacs
$ sudo apt install emacs
# for sublime
$ wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
$ sudo apt install apt-transport-https
$ echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
$ sudo apt update
$ sudo apt install sublime-text
Create an SSH private-public key pair to facilitate logging in to a remote machine without typing a password:
$ ssh-keygen -t rsa -b 4096
When prompted, accept the default location (~/.ssh/id_rsa
)
and default passphrase (i.e., empty for none).
Install rbenv as well as ruby-build (a useful rbenv plugin). Both steps are accomplished via the rbenv-installer script:
$ wget -q https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer -O- | bash
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
$ exec $SHELL
Install Ruby.
# first install some Ruby dependencies
$ sudo apt install zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev
$ rbenv install 2.6.6 # this step takes several minutes
$ rbenv global 2.6.6 # set default ruby version
$ ruby -v # confirm it works
Install Rails.
Rails requires both a JavaScript runtime and the Yarn package manager. NVM is the node package manager which allows you to install and manage different NodeJS installations.
$ sudo apt install curl
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
$ Close and reopen the terminal (or run source ~/.bashrc)
$ nvm install 12 --lts
$ nvm alias default 12
$ npm install yarn -g
$ sudo npm install yarn -g #
Install the Rails gem:
$ gem install --no-document rails -v 6.0.3
Confirm Rails installation with a system test.
$ mkdir rails_work
$ cd rails_work
$ rails new demo
$ cd demo
$ rake about # version info, checks for a javascript runtime, etc
$ rails server
The output of the last command should look something like:
=> Booting Puma
=> Rails 6.0.3.x application starting in development
=> Run `rails server --help` for more startup options
Puma starting in single mode...
* Version 4.3.5 (ruby 2.6.6-pxx), codename: Mysterious Traveller
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://127.0.0.1:3000
* Listening on tcp://[::1]:3000
Use Ctrl-C to stop
You can kill the server with Ctrl-C (in the terminal window in which it is running):
^C- Gracefully stopping, waiting for requests to finish
=== puma shutdown: yyyy-mm-dd hh:mm:ss -0400 ===
- Goodbye!
Exiting
Note: The installation of a full-fledged IDE is optional. This part of the setup instructions is not part of project 1. In fact, it will not be required for any part of the course. Many developers just use their favorite editor (emacs, vim, sublime, etc.) for Ruby. The choice, however, is yours.
Two good IDEs are JetBrains' RubyMine (popular for Ruby development)
and Microsoft's Visual Studio Code (aka VSCode, not to be confused
with Microsoft's Visual Studio).
JetBrains offers a free license for students. VSCode is free for everyone.
Pick one.
RubyMine (JetBrains)
Create a student account with JetBrains at www.jetbrains.com/student.
Download and install the RubyMine IDE.
$ sudo snap install rubymine --classic
Run it:
$ rubymine
When you run RubyMine, you will be prompted to activate your (free) license by entering your JetBrains student account information.
VS Code (Microsoft)
Install the IDE.
$ sudo snap install code --classic
Configure the IDE (see the docs) and install extensions to help with web development.