Software Engineering

Homework 1: Development Environment Setup

The goal of this homework is to ensure that you have a functioning Rails development environment with which to complete the remaining Boot Camp homeworks. To accomplish this goal, you must set up a development environment as per the following instructions.

Before I jump into the instructions, I need to clear up a little terminology. In this and future homeworks, you will be using a virtual machine (VM). A VM is where one OS is run inside of another OS (rather than directly on a physical machine). The parent OS is called the host OS. For example, imagine you have a Windows computer—that’ll be the host OS. You can use the VirtualBox software to install a Linux OS within the host Windows OS and to run a Linux VM as if it were a Windows program.

Instructions

  1. If you are doing this homework using the university Wi-Fi, make sure that you are using the “um” network. Do not use the “um-guest” network, which has ports blocked that are needed for some of the commands below to work properly.

  2. Activate your Piazza account (http://piazza.com/) for the course. You should have received an email invitation (sent to your university email address). If did you not receive an email, contact the instructor. If you run into any technical problem or have any question during the course, post your question to Piazza (Q&A). The instructor as well as your fellow students have the opportunity to answer your question. Moreover, other students will be able to see your question and the answer, saving them the time and trouble of asking the same question.

  3. Sign up for GitHub at https://github.com/ (if you haven’t already previously done so). Be sure not to lose your GitHub username and password.

  4. Install the Visual Studio Code (VS Code) editor (https://code.visualstudio.com/). Use the latest stable version. Additionally, within VS Code, install the following extensions:
    • Rails
    • Ruby
    • erb
    • markdownlint
    • Markdown PDF
    • Code Spell Checker
  5. You will need to have a Bash shell with SSH client. Windows users should download and install Git for the Windows platform (http://git-scm.com/download/win), which comes with a Bash shell and SSH client. OSX users have this software by default. Debian/Ubuntu Linux users have the shell, but may need to install the “openssh-client” package (if it’s not already installed by default).

  6. Download and install VirtualBox (https://www.virtualbox.org/). You will be using this software to run an Ubuntu Linux virtual machine. This VM will house the majority of your Rails development tools. All students in this course must use an Ubuntu development environment. The rationale is that by having all students standardize on an environment, they will be better able to collaborate and learn from one another.

  7. Download and install Vagrant (https://www.vagrantup.com/). Vagrant is used to package, distribute, and run custom-configured VMs. I have prepared a Vagrant “box” for you as you will see below.

  8. Create a folder called “workspace”. This folder is where all your Rails projects for the course will go.

  9. Download the file Vagrantfile and save it in your workspace folder. To do so, you may be able to right-click on this hyperlink and select “Save Link As…” (or similar) from the context menu. Make sure that no file suffix (e.g., “.txt”) gets added to your Vagrantfile.

  10. Launch a terminal. In Windows, it involves launching “Git Bash”. In OSX, this involves launching the “Terminal” app. I assume that Linux users need no clarification here.

  11. In the terminal, change directory (using the cd command) to the workspace folder. Note: We will be using the command-line a lot this semester. If you’re new to the command-line, I highly suggest you spend some time on your own learning about it—for example, Codecademy has a course: https://www.codecademy.com/learn/learn-the-command-line

  12. Run the command vagrant up to download and initialize a Vagrant box. BEWARE! This command (1) may take a long time to complete, (2) downloads a big file (~700MB), and (3) performs at least one processor-intensive compilation (of Ruby). Also, this command will not complete correctly if you are on the “um-guest” network. If using the campus Wi-Fi, use the “um” network. Once this command completes, you will have a running Ubuntu Linux VM (headless).

  13. Run the command vagrant ssh to SSH into the Linux VM. If you’re prompted for a passphrase, just hit enter. If you’re prompted for a password, enter “vagrant” (without the quotes). You should see a command prompt that looks like this: [vagrant@ubuntu-xenial:~] followed by a $ prompt. If you use the ls -l command, you will see a list of files in the current directory. You will see among them a workspace folder (actually a symbolic link to the folder /vagrant).

  14. Change directory (using the cd command) to the workspace folder. Note that this folder is synced with the workspace folder on your host OS. That is, changes you make in the folder on either side (VM or host OS) are instantly applied to the other side.

  15. Enter the command git clone https://github.com/sdflem/sample_app.git to use Git to download an example project. You should now see a “sample_app” folder inside the workspace folder. Note that the workspace folder is synced with your host OS, so you should also see sample_app in your host file explorer. The reason for syncing this folder is that it will later enable you to use a GUI code editor to work on your code files.

  16. Change directory (using the cd command) to the sample_app folder. When you run this command, RVM should print a message, which lets you know it’s working. If you don’t see a message from RVM, then something is wrong. A common problem is that your terminal application is not configured to run as a “login” shell. This issue seems to come up the most for Linux users, or users of more exotic terminal applications. Typically, the solution can be found in the terminal application’s settings.

  17. Run these three commands to set up the web app project (i.e., prepare it to run). The first two commands may take a while to complete because they download and install a lot of Ruby gems.
    • gem install bundler
    • bundle install --without production
    • rake db:setup
  18. The project comes with some automated tests. Run the command rake test to execute the tests. You should see that all the tests passed.

  19. Take a screenshot that shows your desktop and terminal with the notification that all the tests passed. Save this screenshot to be submitted later.

  20. Start up the Rails web app server with the command rails s -b 0.0.0.0 (those are zeros). You should see that the server has started without error. Note that this command will not “return” like other commands—that is the command prompt will not reappear until you kill the process (covered below).

  21. Now open the URL http://localhost:3000 in a web browser. A “Welcome to the Sample App” web page should appear.

  22. In the web app, log in with the email example@railstutorial.org and the password foobar. You will see that it is a twitter-like app.

  23. In the app, create a post that contains your university email username (e.g., “sdflming rocks!”). Hint: You may need to click the “Home” link.

  24. Take a screenshot of your desktop with the web app showing and your post visible. Save this screenshot to be submitted later.

Congratulations! You’ve completed the main part of this homework.

Shutting Everything Down

To shut down everything:

  1. Back in the terminal, type Ctrl-C to kill the Rails server.

  2. Enter the command exit to logout of the VM.

  3. Enter the command vagrant halt to shut down the VM.

Later, when you need to start the VM again, just run vagrant up (should be much faster than last time) and use vagrant ssh to log in again.

What to Submit

To get credit for completing this homework assignment:

Rubric

Full marks: 100

Below, the top-level number is the items total point value. If an item is not submitted at all, 0 points will be awarded for that item. The sub-bullets indicate standard deductions for errors in a submitted item. The deduction list below may not be complete because there may be mistakes that we did not expect. The deduction for an unexpected mistake will be assessed at the time it’s discovered and will reflect how severe the instructor thinks the mistake is.

Other deductions:

© Scott D. Fleming 2018 • Made with GitHub Pages and Markdown