Using gems in a script or irb

D

Demonic Software

[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.
 
J

Joel VanderWerf

Demonic said:
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.
 
D

Demonic Software

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

Thanks Joel.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top