Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(...)in `require': no such file to load -- 'gemname' (LoadError)

Tags:

ruby

require

I haven been all day training to fix this problem but i couldn't.

The question is easy, i don't want to put anymore the require 'rubygems' line everytime i require a gem...

If i put the require 'rubygems' before any other "require" the file runs perfect but if i don't put the require 'rubygems' line the following error occurs:

(...)in `require': no such file to load -- 'gemname' (LoadError)

I suspect that may be there is some path remaining where to check out the gems repository.

I want to ask you if there is a way to do this.

Thanks a lot.

Cheers, Juan.

like image 551
flyer88 Avatar asked Nov 27 '22 15:11

flyer88


2 Answers

You could invoke you ruby script with

ruby -rubygems script.rb

or add rubygems to RUBYOPT

$ export RUBYOPT="rubygems"
like image 123
Peter Krenn Avatar answered Dec 10 '22 01:12

Peter Krenn


put

require 'rubygems'

as first line of your ruby code and be safe. of course you can invoke with -rubygems switch (as Peter Krenn wrote) instead of it

like image 31
andrej Avatar answered Dec 10 '22 02:12

andrej