[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Using gems in a script or irb

Demonic Software

3/13/2008 2:45:00 AM

[Note: parts of this message were removed to make it a legal post.]

Hello,

I am in the process of trying to setup a ruby development environment (not
for Ruby on Rails), and I was wondering how I go about using ruby gems in a
script or from irb. I have tried setting the environment variables in the
two following ways:

$ printenv | grep GEM
GEM_HOME=/usr/lib/ruby/gems/1.8/gems/
GEM_PATH=/usr/lib/ruby/gems/1.8/gems/
$ ls $GEM_PATH
hoe-1.5.0 hoe-1.5.1 ParseTree-2.1.1 rake-0.8.1 ruby2ruby-1.1.8
rubyforge-0.4.4 rubyforge-0.4.5 rubygems-update-1.0.1 RubyInline-3.6.6
$ irb
irb(main):001:0> require "ruby2ruby"
LoadError: no such file to load -- ruby2ruby
from (irb):1:in `require'
from (irb):1
irb(main):002:0>

== and ==
$ printenv | grep GEM
GEM_HOME=/usr/lib/ruby/gems/1.8/
GEM_PATH=/usr/lib/ruby/gems/1.8/
$ ls $GEM_PATH
cache doc gems source_cache specifications
$ irb
irb(main):001:0> require 'ruby2ruby'
LoadError: no such file to load -- ruby2ruby
from (irb):1:in `require'
from (irb):1
irb(main):002:0>

Every time I google a majority of the links point to some documentation on
how to set-up and configure Ruby on Rails. I am just trying to set-up an
environment, where I can write a script and use gems directly in the script
or from the irb prompt. For example:

#foobar.rb
require 'foo' # where foo is a module in my gems directory
foo.new('bar')

$ruby foobar.rb

Thanks in advance for your help.

2 Answers

Joel VanderWerf

3/13/2008 2:54:00 AM

0

Demonic Software wrote:
> I am in the process of trying to setup a ruby development environment (not
> for Ruby on Rails), and I was wondering how I go about using ruby gems in a
> script or from irb.

This works:

$ echo $RUBYOPT
rubygems

That causes ruby to run as if you specified -rubygems on the command
line, and there is a lib called ubygems.rb (without the "r") that this
loads and which then sets up gems.

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

Demonic Software

3/13/2008 3:08:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

Thanks Joel.

On Wed, Mar 12, 2008 at 9:53 PM, Joel VanderWerf <vjoel@path.berkeley.edu>
wrote:

> Demonic Software wrote:
> > I am in the process of trying to setup a ruby development environment
> (not
> > for Ruby on Rails), and I was wondering how I go about using ruby gems
> in a
> > script or from irb.
>
> This works:
>
> $ echo $RUBYOPT
> rubygems
>
> That causes ruby to run as if you specified -rubygems on the command
> line, and there is a lib called ubygems.rb (without the "r") that this
> loads and which then sets up gems.
>
> --
> vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
>
>