No such file to load -- rubygems (LoadError)

Discussion in 'Ruby' started by Chih tung Chao, Dec 15, 2010.

  1. Hi all

    I have use ruby to write a shell script to send email automatic, then i
    use "#ruby auto_send_mail_for_hk.rb" command to test it and all is
    correct, but i got following error when i set it to crontab tast for
    automatic run

    Please help me, thanks


    /root/scripts/auto_send_mail_for_hk.rb:7:in `require': No such file to
    load -- rubygems (LoadError)
    from /root/scripts/auto_send_mail_for_hk.rb:7

    --
    Posted via http://www.ruby-forum.com/.
    Chih tung Chao, Dec 15, 2010
    #1
    1. Advertising

  2. Chih tung Chao

    Ryan Davis Guest

    On Dec 15, 2010, at 00:55 , Chih tung Chao wrote:

    > Hi all
    >=20
    > I have use ruby to write a shell script to send email automatic, then =

    i
    > use "#ruby auto_send_mail_for_hk.rb" command to test it and all is
    > correct, but i got following error when i set it to crontab tast for
    > automatic run
    >=20
    > Please help me, thanks
    >=20
    >=20
    > /root/scripts/auto_send_mail_for_hk.rb:7:in `require': No such file to
    > load -- rubygems (LoadError)
    > from /root/scripts/auto_send_mail_for_hk.rb:7


    env | grep RUBY

    you're probably activating rubygems via your environment. Your script =
    should have:

    require "rubygems"

    before requiring your email gem.
    Ryan Davis, Dec 15, 2010
    #2
    1. Advertising

  3. Ryan Davis wrote in post #968509:
    > On Dec 15, 2010, at 00:55 , Chih tung Chao wrote:
    >
    >> /root/scripts/auto_send_mail_for_hk.rb:7:in `require': No such file to
    >> load -- rubygems (LoadError)
    >> from /root/scripts/auto_send_mail_for_hk.rb:7

    >
    > env | grep RUBY
    >
    > you're probably activating rubygems via your environment. Your script
    > should have:
    >
    > require "rubygems"
    >
    > before requiring your email gem.



    My script already have require "rubygems", and how to set rubygems
    environment in my system ?

    --
    Posted via http://www.ruby-forum.com/.
    Chih tung Chao, Dec 15, 2010
    #3
  4. On Wed, Dec 15, 2010 at 10:18 AM, Chih tung Chao <> wrote=
    :
    > Ryan Davis wrote in post #968509:
    >> On Dec 15, 2010, at 00:55 , Chih tung Chao wrote:
    >>
    >>> /root/scripts/auto_send_mail_for_hk.rb:7:in `require': No such file to
    >>> load -- rubygems (LoadError)
    >>> =A0 =A0 =A0 =A0from /root/scripts/auto_send_mail_for_hk.rb:7

    >>
    >> env | grep RUBY
    >>
    >> you're probably activating rubygems via your environment. Your script
    >> should have:
    >>
    >> require "rubygems"
    >>
    >> before requiring your email gem.

    >
    >
    > My script already have require "rubygems", and how to set rubygems
    > environment in my system ?


    http://docs.rubygems.org/read/chapter/3

    Jesus.
    Jesús Gabriel y Galán, Dec 15, 2010
    #4
  5. Chih tung Chao

    Ryan Davis Guest

    On Dec 15, 2010, at 1:18, Chih tung Chao <> wrote:

    > My script already have require "rubygems"


    Then you're prolly using a different ruby in cron than on cmdline. Use full p=
    ath to ruby in crontab=
    Ryan Davis, Dec 15, 2010
    #5
  6. Chih tung Chao

    Abinoam Jr. Guest

    It's probably "env-related"

    Look at:

    http://stackoverflow.com/questions/2585244/rake-task-via-cron-problem-loading-

    http://groups.google.com/group/rubyonrails-talk/msg/128b59ee57473cfb

    For debugging, run "env" in a shell and at cron and see the differences.

    Abinoam Jr.

    On Wed, Dec 15, 2010 at 7:51 AM, Ryan Davis <> wrote:
    >
    >
    > On Dec 15, 2010, at 1:18, Chih tung Chao <> wrote:
    >
    >> My script already have require "rubygems"

    >
    > Then you're prolly using a different ruby in cron than on cmdline. Use full path to ruby in crontab
    >
    Abinoam Jr., Dec 15, 2010
    #6
  7. Chih tung Chao

    Ryan Davis Guest

    Ryan Davis, Dec 15, 2010
    #7
    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. Ruby Ruby
    Replies:
    0
    Views:
    189
    Ruby Ruby
    Apr 22, 2004
  2. Erik Veenstra
    Replies:
    4
    Views:
    807
    Austin Ziegler
    Feb 4, 2005
  3. Brian Takita
    Replies:
    7
    Views:
    317
    Brian Takita
    May 24, 2005
  4. Zoong Pham
    Replies:
    1
    Views:
    272
    Chad Fowler
    Aug 11, 2005
  5. Bhupendra Mishra
    Replies:
    2
    Views:
    730
    Bhupendra Mishra
    Jan 27, 2011
Loading...

Share This Page