PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Using gems in a script or irb
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Using gems in a script or irb

Réponse
 
LinkBack Outils de la discussion
Vieux 13/03/2008, 03h44   #1
Demonic Software
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Using gems in a script or irb

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

  Réponse avec citation
Vieux 13/03/2008, 03h53   #2
Joel VanderWerf
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Using gems in a script or irb

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

  Réponse avec citation
Vieux 13/03/2008, 04h08   #3
Demonic Software
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Using gems in a script or irb

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


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 17h37.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10237 seconds with 11 queries