Sunday, September 06, 2009

Installing Spree eCommerce

I'm looking to update a website that was written in a decent, but not great website creator application. I want to write it in Rails (yea!) because I had such great fun creating the Zepatter.com website. I mean, that took less than 12 hours from sitting down with the GIMP to getting the application installed on the hosting environment. And a huge chunk of that 12 hours was figuring out how to get the hosting environment configured correctly. hehe.

So, I'm looking for an eCommerce engine for Rails. Yes, I could create the whole shopping cart and payment gateway on my own because there are tons of tutorials and general advice. However, I suspect that if I could find a full-featured engine, then someone else will have thought of -- and solved -- problems that will take me time to recognize and address.

So I came across Spree eCommerce.

However, I haven't updated Rails on my system in a while and Spree requires Rails 2.3.2. So I start by doing a

sudo gem update rails


which gets me to Rails 2.3.4. However, Spree wants 2.3.2 ONLY. So I remove Rails 2.3.4 and install 2.3.2. Then I install Spree according to the instructions. Then I try to create my first Spree application with:
spree mystore
Unfortunately, I got this error:
/usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:578:in `report_activate_error': RubyGem version error: hoe(1.5.3 not >= 1.8.0) (Gem::LoadError)

OK. No problem. Need to update hoe
~/src:sudo gem update hoe
Updating installed gems
Updating hoe
ERROR: While executing gem ... (Gem::InstallError)
hoe requires RubyGems version >= 1.3.1

OK. No problem. Need to update gem. After all,
~/src:gem --version
1.2.0
So I do the following:
~/src:sudo gem update --system
Updating RubyGems
Nothing to update
OK, this may be a problem. Referring to the rubygems documentation, one needs to do the following:
gem install rubygems-update
update_rubygems
However, this failed with:
~/src:sudo update_rubygems
/usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:578:in `report_activate_error': Could not find RubyGem session (>= 0) (Gem::LoadError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:134:in `activate'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:158:in `activate'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:157:in `each'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:157:in `activate'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:49:in `gem'
from /usr/local/bin/update_rubygems:18
Mark Howe has a helpful blog on the matter.

In the end, the trick was to uninstall the partly installed rubygems 1.3.5, install rubygems 1.3.4, then do the
update_rubygems
And all was well. I was able to update hoe and then successfully run
spree mystore

8 comments:

  1. Glad you got it working. I just wanted to clarify that while Spree does in fact require a specific Rails version, in most cases it can peacefully coexist with other versions.

    ReplyDelete
  2. @Sean; thanks for the comment. Is there a reference for folks who need to run Spree with a different rails version? Or was the limitation imposed at installation time, which was my experience?

    - Peter

    ReplyDelete
  3. /usr/lib/ruby/site_ruby/1.8/rubygems.rb:777:in `report_activate_error': Could not find RubyGem spree (>= 0) (Gem::LoadError)
    from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:211:in `activate'
    from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1056:in `gem'
    from /home/oujevis1/ruby/gems/bin/spree:18

    It looks like yours but not really.
    Did you face this too, do you have any idea ?

    ReplyDelete
  4. @Stefan;

    It looks like your environment couldn't find the spree gem. Does it appear in your "gem list --local" output?

    - Peter

    ReplyDelete
  5. Yes. I just checked and here is the output (near the end, spee version 0.9.4:

    gem list --local

    *** LOCAL GEMS ***

    actionmailer (2.3.5)
    actionpack (2.3.5)
    activemerchant (1.5.1, 1.4.1)
    activerecord (2.3.5)
    activerecord-tableless (0.1.0)
    activeresource (2.3.5)
    activesupport (2.3.5)
    builder (2.1.2)
    calendar_date_select (1.15)
    cgi_multipart_eof_fix (2.5.0)
    chronic (0.2.3)
    daemons (1.0.10)
    gem_plugin (0.2.3)
    gemcutter (0.4.1)
    git (1.2.5)
    haml-edge (2.3.166, 2.3.164)
    highline (1.5.2)
    hoe (2.5.0)
    jeweler (1.4.0)
    json_pure (1.2.2, 1.2.0)
    polyglot (0.3.0)
    rack (1.1.0, 1.0.1)
    rails (2.3.5)
    rake (0.8.7)
    rspec (1.3.0)
    rspec-rails (1.3.2)
    rubyforge (2.0.3)
    rubygems-update (1.3.6)
    searchlogic (2.4.11)
    spree (0.9.4)
    tlsmail (0.0.1)
    treetop (1.4.4)

    ReplyDelete
  6. Yes it is.
    I just checked and I foud near the end of the list spee version 0.9.4
    I also checked in ~/ruby/gems/bin/ and the spree binary is there.

    ReplyDelete
  7. Hi Stefan,

    OK, with the gem installed, then the next area to examine would be the rails environment. What happens when you run script/console and then do:

    require 'spree'

    ReplyDelete
  8. Well that was a problem with my hosting provider.
    I checked with him and he has the things done at server level.
    It's now working.

    ReplyDelete