Assignment 0: Setting Up Your System

In this assignment, you will set up your computer with Ruby, RubyGems, Ruby on Rails, Sqlite, and Mongrel.

Read through this, and then see at the very end a checklist of what you need to submit

You must have the following versions:

Installation Tips

Operating Systems

RubyGems

RubyGems is the Ruby package manager and deployment system. It provides for loading software packages into your Ruby system so that you can use them in your own work. Rails itself is delivered as a Gem.

In the typical case, you type


gem install <package>

where package is the name of the package you want. In some cases you will be given a list of versions and operating systems — try to pick a recent version for your operating system (Windows is MSWin32). On the Mac and Linux, you should be the superuser when you use gem.

On occasion, the various installers may leave the RubyGems system in a lower version than we’d like. To update the RubyGems system to the latest version, do


# On the Mac and Linux, run following as su or use sudo
gem update --system
#
# On some systems, you may only get up to 1.1.1, and will have to additionally:
gem install rubygems-update
update_rubygems

(For more information on getting to the latest version of RubyGems, see http://blog.segment7.net/articles/2008/06/21/rubygems-1-2-0.

Sqlite3

If you don’t use an all-in-one setup such as “Instant Rails” you will probably have to install Sqlite3 yourself. The installers are here: http://www.sqlite.org/download.html. On Linux and OS X, you may be able to use your system package manager (apt-get, aptitude, Darwin Ports, etc.).

On Windows, you will need both the sqlite-3_6_2.zip AND the sqlitedll-3_6_2.zip downloads. The contents of these two ZIPs should go in the same place, say, C:\Sqlite-3_6_2

After you’ve installed and/or placed the unzipped files in the proper place according to the instructions, you may have to add the directory to your path. On Windows (approximately): Control Panel / System / Advanced tab / Environment Variables button / System variables / Pick “Path” and edit, and then add the path preceded by a semi-colon (;C:\Sqlite3 or wherever you put it). On OS X and Linux, you should add the path in your .bash_profile or a similar file.

Sqlite3 Gem

In the typical case, you should be able to do:


gem install sqlite3-ruby

Some report that on Windows XP, there are problems getting the latest version. If need be, try version 1.2.3:


gem install --version 1.2.3 sqlite3-ruby

If you have problems with your setup, post comments here. If you have a laptop and need help getting set up, bring your laptop to section.

Here’s a little program that will attempt to load the different components and print out the version of each; you may find it useful for analyzing your system and we’d like you to provide the output as a part of your submission. Click “View Plain”, then copy the code to your clipboard, and then into a file called “versions.rb”; then you sould be able to type ruby versions.rb.


def myrequire(r)
require r
rescue Exception => e
puts "require failed: #{e}"
end

def check_sqlite3
tempname = "test.sqlite#{3+rand}"
db = SQLite3::Database.new(tempname)
puts "And . . . Connect to Sqlite says version is: #{db.execute('select sqlite_version()') }"
db.close
File.unlink(tempname)
end

myrequire 'rubygems'
myrequire 'initializer'
myrequire 'mongrel'
myrequire 'sqlite3'

puts "----- Software version check at #{Time.now}\n\n"
[
{ :name => 'Ruby', :version => 'RUBY_VERSION' },
{ :name => 'RubyGems', :version => 'Gem::RubyGemsVersion' },
{ :name => 'Rails', :version => 'Rails::VERSION::STRING' },
{ :name => 'Mongrel', :version => 'Mongrel::Const::MONGREL_VERSION' },
{ :name => 'Sqlite', :version => '`sqlite3 -version`' },
].each do |component|
puts "#{component[:name]}: #{eval(component[:version]) rescue 'Exception: %s' % $!.message}"
end

check_sqlite3 rescue 'Sqlite3 check: Exception: %s' % $!.message

puts `gem list`

How to Submit this Assignment

Once you have everything set up, go to the command-line prompt, and change your directory to a temporary directory. Then type


rails assn0

Then cd into that directory, and type:


ruby script/server

You should see something like the following:


jgnmbair:assn0 jgn$ script/server
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails 2.1.1 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready.  TERM => stop.  USR2 => restart.  INT => stop (no restart).
** Rails signals registered.  HUP => reload (without restart).  It might not work well.
** Mongrel 1.1.5 available at 0.0.0.0:3000
** Use CTRL-C to stop.

Now browse to http://localhost:3000 — You should see something like this:

Click “About your application’s environment.” We want a screenshot like the following:

Checklist for Submission

  1. Make your screenshot, and save it as JPG or PNG. Base the file name on your own name, e.g., john_g_norman.jpg
  2. Paste into your e-mail the output from the versions.rb program above.
  3. Type the following into irb, and determine the secret message:
    
    "94G5B>2!W87,@8W)E871E9\"!B>2!-871Z+@``\n".unpack('u*')[0]
    
  4. E-mail the screenshot, the output from versions.rb, and the secret message to your TA Sunday, Oct. 5 Sep. 27 (for the legalistic, and for those in different timezones, please get assignments in by 4 AM EST the following day; e.g., in this case, by Monday, Oct. 6 Sep. 28, 4 AM EST).


Viewing 65 Comments

blog comments powered by Disqus