require - not loading gem

Discussion in 'Ruby' started by paul h, Dec 13, 2010.

  1. paul h

    paul h Guest

    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

    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
    paul h, Dec 13, 2010
    #1
    1. Advertising

  2. paul h

    Walton Hoops Guest

    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
    >
    Walton Hoops, Dec 13, 2010
    #2
    1. Advertising

  3. paul h

    paul h Guest

    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.
    paul h, Dec 14, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. han
    Replies:
    1
    Views:
    117
    Lyle Johnson
    Oct 24, 2005
  2. Michael Glaesemann

    gem query finds gem, yet require fails

    Michael Glaesemann, Nov 12, 2006, in forum: Ruby
    Replies:
    5
    Views:
    147
    Michael Glaesemann
    Nov 26, 2006
  3. Austin 7873
    Replies:
    5
    Views:
    179
    Eric Hodel
    Jan 27, 2007
  4. Daniel Berger
    Replies:
    2
    Views:
    146
    Daniel Berger
    Sep 12, 2008
  5. James Calfee
    Replies:
    0
    Views:
    144
    James Calfee
    Nov 25, 2009
Loading...

Share This Page