Thanks Ed

Ed Roberts

Ed Roberts (1941 - 2010)

I was a lucky kid. I grew up with my grandparents and my mom; all of them pushed me hard to learn. They never told me what to focus on, they just did their best to embrace the things I fell in love with. One of those things was computers. If it wasn't for Ed Roberts there was no way my family could afford for me to learn how to program.

Ed cofounded MITS in 1969 and by 1975 MITS launched the Altair 8800. The Altair 8800 was the first successful personal computer (read: "They sold lots of them") and it was the computer that Microsoft developed their first commercial product for. The Altair was the computer that inspired Steve Jobs and Steve Wozniak to start a little company called Apple. By 1979 Apple has completely overshadowed MITS, but what Ed did was create the business model the PC world would follow to this day - including the concept of selling upgrades to your PC, peripherals, computer magazines, computer stores, Microsoft software and Intel CPU's.

Ed jump-started the industry that changed the world and I can't imagine what we would have today if Ed didn't do what he did.

Thanks Ed.

Intro

Some people want to start doing some Rails 3.0 Beta work on Ruby 1.9.2 on their development machines. I'm tossing this up here to have something to point people to when they have questions.

I'm making a few assumptions:

  1. You're on OS X Snow Leopard (x86_64)
  2. You have macports install (or readline installed somewhere else on your box)

Install Ruby Version Manager

$ sudo gem install rvm
$ rvm-install

Install Ruby 1.9.2 HEAD (i.e. latest development code)

Note: Your readline directory may be in a different spot.

$ rvm install 1.9.2-head -C --enable-shared,--with-readline-dir=/opt/local,--build=x86_64-apple-darwin10
Installing Ruby from source to: /Users/mturner/.rvm/rubies/ruby-1.9.2-head

Running autoconf

Configuring ruby-1.9.2-head, this may take a while depending on your cpu(s)...

Compiling ruby-1.9.2-head, this may take a while, depending on your cpu(s)...

Installing ruby-1.9.2-head

Installation of ruby-1.9.2-head is complete.

Updating rubygems for ruby-1.9.2-head

Installing gems for ruby-1.9.2-head.

Installing rake

Installation of gems for ruby-1.9.2-head is complete.

$ ruby -v
ruby 1.9.2dev

Create a Rails 3.0 Gem set and switch to it

This processes allows us to isolate the Rails 3.0 environment gems.

$ rvm gemset create rails3beta
$ rvm 1.9.2-head@rails3beta

Install the Rails 3.0 Gems and dependencies

$ gem install sqlite3-ruby
$ env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
$ gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
$ gem install rails --pre

Done

Hopefully everything worked:

$ ruby -v
  ruby 1.9.2dev (2010-02-25 trunk 26759) [x86_64-darwin10.2.0]
$ rails --version
  Rails 3.0.0.beta
$ gem list
  *** LOCAL GEMS ***

  abstract (1.0.0)
  actionmailer (3.0.0.beta)
  actionpack (3.0.0.beta)
  activemodel (3.0.0.beta)
  activerecord (3.0.0.beta)
  activeresource (3.0.0.beta)
  activesupport (3.0.0.beta, 2.3.5)
  arel (0.2.1)
  builder (2.1.2)
  bundler (0.9.7)
  erubis (2.6.5)
  i18n (0.3.3)
  mail (2.1.3)
  memcache-client (1.7.8)
  mime-types (1.16)
  mysql (2.8.1)
  rack (1.1.0)
  rack-mount (0.6.0, 0.4.7)
  rack-test (0.5.3)
  rails (3.0.0.beta)
  railties (3.0.0.beta)
  rake (0.8.7)
  sqlite3-ruby (1.2.5)
  text-format (1.0.0)
  text-hyphen (1.0.0)
  thor (0.13.3)
  tzinfo (0.3.16)

Switching back to your system Ruby

rvm system

Back to your Rails3.0 environment

rvm 1.9.2-head@rails3beta

Use your RVM environment as your Default

rvm 1.9.2-head@rails3beta --default

Read more about RVM over at http://rvm.beginrescueend.com/

Update 04/16/2010

Updated to reflect the recent changes in RVM.

I was assisting aridlous on irc while he was experiencing an issue launching the rails console in a Rails 3.0 beta app.

He was getting the following error:

$ script/console
/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- set (LoadError)
   from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
   from /opt/local/lib/ruby/gems/1.8/gems/bundler-0.9.7/lib/bundler/resolver.rb:1
   from /opt/local/lib/ruby/gems/1.8/gems/bundler-0.9.7/lib/bundler/runtime.rb:95:in `specs'
   from /opt/local/lib/ruby/gems/1.8/gems/bundler-0.9.7/lib/bundler/runtime.rb:81:in `specs_for'
   from /opt/local/lib/ruby/gems/1.8/gems/bundler-0.9.7/lib/bundler/runtime.rb:18:in `setup'
   from /opt/local/lib/ruby/gems/1.8/gems/bundler-0.9.7/lib/bundler.rb:66:in `setup'
   from /Users/User/dev/sekret/config/../config/preinitializer.rb:34
   from /Users/User/dev/sekret/config/boot.rb:28:in `load'
   from /Users/User/dev/sekret/config/boot.rb:28:in `preinitialize'
   from /Users/User/dev/sekret/config/boot.rb:10:in `boot!'
   from /Users/User/dev/sekret/config/boot.rb:129
   from script/console:2:in `require'
   from script/console:2

This appears to only affect folks using RVM and Bundler.

After a little sleuthing it appeared that RVM was setting a blank GEM_HOME environment variable when you leave the ruby version set to default.

$  env | grep GEM_HOME
GEM_HOME=

There are two easy fixes

1) unset GEM_HOME or 2) rvm system

Both of these clear the GEM_HOME environment variable.

aridlous dug around the bundler src after I helped him out and came back with the following tib-bit. I'd write a patch and probably will but I'm just too tired at the moment.

interesting, but the bug seems to be possibly 2 things: empty GEM_HOME should not be used, and when the join occurs I think it is creating an invalid GEM_PATH=":/Users/User/.gem/ruby/1.8:/opt/local/lib/ruby/gems/1.8:" ... it should not have that leading ':'

UPDATE: Filed an issue in Bundlers issue tracker

UPDATE 2: Fixed in 55509f

I enjoy using OpenSolaris when I can, and I've been using it for a couple small Ruby on Rails deployments. I've received a few questions recently about deploying Ruby on Rails app on OpenSolaris, so to kill a few 'birds' with one stone. I'm throwing this post together so that I can just point them here and let them run with it.

Sun has an easy to install meta-package called amp that includes Apache 2.2, Apache 2.2 DTrace probes, MySQL Server 5.1 & PHP. If you've never used Solaris/OpenSolaris before the pfexec command will seem foreign to you. Don't let it worry you its part of the Solaris RBAC (Role Based Access Control) by default the non-root user you created during the install has the root user role and can execute commands as root if you use pfexec.

I'm assuming you're starting from scratch on an OpenSolaris 2009.06 server with nothing extra installed. I also assume you've had some experience with a Unix/Linux variant.

Basics

We want to install some of the GNU stack including gmake, gcc and git + subversion. We're going to install git from source to be sure we're on the latest release.

gmake, gcc, subversion and curl

Commands:

  $ pfexec pkg install SUNWgmake
  $ pfexec pkg install SUNWgcc
  $ pfexec pkg install SUNWsvn
  $ pfexec pkg install SUNWcurl

git

curl is required to build git don't skip installing SUNWcurl from above.

Note: There seems to be an issue with building versions of git newer than 1.6.0.6 on OpenSolaris 2009.06. I'll figure out why but in the meantime I've provided instructions for installing git 1.6.0.6. Please verify that /usr/local/bin is in your $PATH.

Commands:

  $ pfexec mkdir -p /opt/src
  $ pfexec chmod 777 /opt/src
  $ cd /opt/src
  $ wget http://kernel.org/pub/software/scm/git/git-1.6.0.6.tar.gz
  $ tar xzf git-1.6.0.6.tar.gz
  $ git-1.6.0.6
  $ ./configure
  $ gmake
  $ pfexec make install 
  $ git --version

Apache Stack (AMP)

Like I noted above, OpenSolaris has a meta-package we can install that will take care of most of this. It will install the following packages for us:

  • MySQL Server 5.1
  • Apache 2.2.30
  • PHP 5.2.9

Commands:

  pfexec pkg install amp

Enable Apache & MySQL Services

By default the Apache and MySQL services are not enabled. To turn them on run the following commands:

Apache 2:

  pfexec svcadm enable http:apache22

MySQL

  pfexec svcadm enable mysql

Ruby & Ruby on Rails

First we are going to use the Sun provided Ruby 1.8.7 package that also installs rubygems. Then we will update rubygems, install the gemcutter gem, add http://gems.github.com as a gem source (for legacy purposes), install the rails gems and finally modify our path to include the gem binaries.

  pfexec pkg install SUNWruby18
  pfexec gem update --system
  pfexec gem install gemcutter
  gem tumble
  gem sources -a http://gems.github.com
  pfexec gem install rails
  echo 'export PATH=/usr/ruby/1.8/bin:$PATH' >> ~/.profile
  echo 'export PATH=/var/ruby/1.8/gem_home/bin:$PATH' >> ~/.profile

(Note: Modifying .profile requires you to re-login to the machine, as it's only read during that point. If you like you can add that same line to your .bashrc file)

Install Database Gems

Mysql:

  pfexec gem install mysql -- --with-mysql-dir=/usr/mysql/5.1

sqlite3

  pfexec gem install sqlite3-ruby

Passenger Installation

We need to install fastthread and passenger, then configure apache to use it. We're going to install passenger from source as it fixes a bug with the use of PTHREAD_STACK_MIN (See here) This is fixed in passenger 2.2.6 and I will update this when that is released.

  pfexec gem install fastthread
  cd /opt/src
  git clone git://github.com/FooBarWidget/passenger.git
  cd passenger
  pfexec ./bin/passenger-install-apache2-module

Apache Configuration

We're going to keep the passenger configuration in it's own file to keep the httpd.conf clean.

Create the file:

  touch /etc/apache2/2.2/conf.d/passenger.conf

Paste the lines from the passenger-install-apache2-module command in that file. My file contains the following:

  LoadModule passenger_module /opt/src/passenger/ext/apache2/mod_passenger.so
  PassengerRoot /opt/src/passenger
  PassengerRuby /usr/ruby/1.8/bin/ruby

Let's Test

Lets create a little rails app to verify that rails and passenger

  pfexec mkdir -p /data/apps
  pfexec chown -R mturner:staff /data/apps
  cd /data/apps
  rails test
  cd test
  ./script/generate controller helloworld index
  pfexec chown -R webservd:webservd test

Lets add a vhost config for apache.

  pfexec vim /etc/apache2/2.2/conf.d/test-site.conf

Here is the contents of my file:

     <VirtualHost *:80>
             ServerName test-site.com
             DocumentRoot /data/apps/test/public

             <Directory /data/apps/test>
              Options +FollowSymLinks -SymLinksIfOwnerMatch +MultiViews -Indexes -ExecCGI
              AllowOverride ALL
              Order allow,deny
              Allow from all
             </Directory>
     
        </VirtualHost>

Add 127.0.0.1 test-site.com to /etc/hosts

Restart Apache

  pfexec svcadm restart http:apache22

Test the site in apache and you see the following:

  Helloworld#index

  Find me in app/views/helloworld/index.html.erb

It Works!!

I loved the first comment to this post on digg. Here it is for public consumption:

I'm a conservative. This morning I was awoken by my alarm clock powered by electricity generated by the public power monopoly regulated by the U.S. Department of Energy.

I then took a shower in the clean water provided by a municipal water utility.

After that, I turned on the TV to one of the FCC-regulated channels to see what the National Weather Service of the National Oceanographic and Atmospheric Administration determined the weather was going to be like, using satellites designed, built, and launched by the National Aeronautics and Space Administration.

I watched this while eating my breakfast of U.S. Department of Agriculture-inspected food and taking the drugs which have been determined as safe by the U.S. Food and Drug Administration.

At the appropriate time, as regulated by the U.S. Congress and kept accurate by the National Institute of Standards and Technology and the U.S. Naval Observatory, I get into my National Highway Traffic Safety Administration-approved automobile and set out to work on the roads build by the local, state, and federal Departments of Transportation, possibly stopping to purchase additional fuel of a quality level determined by the Environmental Protection Agency, using legal tender issued by the Federal Reserve Bank.

On the way out the door I deposit any mail I have to be sent out via the U.S. Postal Service and drop the kids off at the public school.

After spending another day not being maimed or killed at work thanks to the workplace regulations imposed by the Department of Labor and the Occupational Safety and Health administration, enjoying another two meals which again do not kill me because of the USDA, I drive my NHTSA car back home on the DOT roads, to my house which has not burned down in my absence because of the state and local building codes and Fire Marshal's inspection, and which has not been plundered of all its valuables thanks to the local police department.

And then I log on to the internet -- which was developed by the Defense Advanced Research Projects Administration -- and post on Freerepublic.com and Fox News forums about how SOCIALISM in medicine is BAD because the government can't do anything right.

If you connect to Solaris 9 from a OS X or any recent Linux box via SSH, chances are your terminal is set to xterm-color. If you try to use vi or anything you'll see an error like below:

xterm-color: Unknown terminal type

Its easy enough to change the terminal declaration in the preference dialog... but why not teach Solaris 9 to handle the xterm-color terminal type?

This assumes you have the sun freeware tools installed in /usr/sfw/bin.

Download this file and place it in /usr/share/lib/terminfo/x/ Example:

cd /usr/share/lib/terminfo/x/
/usr/sfw/bin/wget http://amerine.net/files/xterm-color

Now that annoying error won't stop vi from working. Enjoy.