From: paul h Date: 2010-12-14T19:20:25+09:00 Subject: Re: require - not loading gem On Dec 13, 6:23 pm, Walton Hoops wrote: > On 12/13/2010 5:55 AM, paul h wrote: > > > > > > > Hi, > > > I have installed the spreadsheet gem to read and write MS Excel files. > > > I have a problem in that when I run the app from the command line I > > get the error: unable to load spreadsheet > > > However, when I run my Cuke features and RSpec tests, the gem is > > loaded up fine, and xls files are read and written as intended - it is > > only a problem when I run the app directly from the command line. > > > I presume this is a problem with my ruby installation, or environment. > > I have looked through the Pickaxe book ref Environment, but culdn't > > find anything to help - and I can't find anything on the site for the > > gem in respect of any support, so if someone could point me in the > > right direction, I'd be eternally grateful. > > > Ubuntu 10.04 > > Ruby 1.8.7 > > You must manually require rubygems in 1.8.x.  In 1.9.x this is no longer > necessary.  Either add require 'rubygems' before require 'spreadsheet' > or run the program with ruby -r rubygems. > > I suspect the reason it works from rspec/cucumber is because there are > themselves gems and must require rubygems to operate. > > > > > App structure: > > > [application root folder] > >      [bin] > >          application (chmod +x) > >      [lib] > >          application.rb (all require statements in here) > >          [application] > >              ... > >              modules > >          [features] > >              ... > >              cuke feature files > >          [spec] > >              ... > >              RSpec spec files > > > If anyone can help I'd appreciate it. At the moment, I can only run > > the app via Cucumber or RSpec, and I need to run it directly from the > > command line. > > > Thanks > > > Paul- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text - Thanks, makes sense.