[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Rubygems on Mac OS X

Geoff Hulette

8/12/2006 6:44:00 PM

I am having a problem getting gems configured properly on my Mac (OS X
10.4.7), hopefully someone here can help me out. I installed ruby and
ruby gems using the instructions at
http://hivelogic.com/articles/2005/12/01/ruby_rails_lighttpd_m....
I am trying to use the XmlSimple gem, but Ruby can't seem to find it, or
any other gems. I did

$ sudo gem install xml-simple

which seemed to work fine. but then

$ ruby -e "require 'xmlsimple'"
-e:1:in `require': no such file to load -- xmlsimple (LoadError)
from -e:1

maybe gems is installed wrong?

some other, possibly useful info:
$ ruby -v
ruby 1.8.4 (2005-12-24) [powerpc-darwin8.7.0]
$ which ruby
/usr/local/bin/ruby
$ gem env
Rubygems Environment:
- VERSION: 0.9.0 (0.9.0)
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
- GEM PATH:
- /usr/local/lib/ruby/gems/1.8
- REMOTE SOURCES:
- http://gems.rub...

Thanks in advance!
-geoff


--
Posted via http://www.ruby-....

12 Answers

lists

8/12/2006 6:58:00 PM

0

Try this:

ruby -e "require 'rubygems'; require 'xml-simple'"

You have to require rubygems first.

-Ryan

On Aug 12, 2006, at 1:43 PM, Geoff Hulette wrote:

> I am having a problem getting gems configured properly on my Mac (OS X
> 10.4.7), hopefully someone here can help me out. I installed ruby and
> ruby gems using the instructions at
> http://hivelogic.com/articles/2...
> ruby_rails_lighttpd_mysql_tiger.
> I am trying to use the XmlSimple gem, but Ruby can't seem to find
> it, or
> any other gems. I did
>
> $ sudo gem install xml-simple
>
> which seemed to work fine. but then
>
> $ ruby -e "require 'xmlsimple'"
> -e:1:in `require': no such file to load -- xmlsimple (LoadError)
> from -e:1
>
> maybe gems is installed wrong?
>
> some other, possibly useful info:
> $ ruby -v
> ruby 1.8.4 (2005-12-24) [powerpc-darwin8.7.0]
> $ which ruby
> /usr/local/bin/ruby
> $ gem env
> Rubygems Environment:
> - VERSION: 0.9.0 (0.9.0)
> - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
> - GEM PATH:
> - /usr/local/lib/ruby/gems/1.8
> - REMOTE SOURCES:
> - http://gems.rub...
>
> Thanks in advance!
> -geoff
>
>
> --
> Posted via http://www.ruby-....
>
>


Chris Gehlker

8/12/2006 7:27:00 PM

0


On Aug 12, 2006, at 11:43 AM, Geoff Hulette wrote:

> I am trying to use the XmlSimple gem, but Ruby can't seem to find
> it, or
> any other gems. I did
>
> $ sudo gem install xml-simple
>
> which seemed to work fine. but then
>
> $ ruby -e "require 'xmlsimple'"
> -e:1:in `require': no such file to load -- xmlsimple (LoadError)
> from -e:1
>
> maybe gems is installed wrong?

I do:
require 'rubygems'
require_gem '<gem_name>'

Which seems to work just fine.


--
The folly of mistaking a paradox for a discovery, a metaphor for a
proof, a torrent of verbiage for a spring of capital truths, and
oneself for an oracle, is inborn in us.
-Paul Valery, poet and philosopher (1871-1945)



Jim Weirich

8/12/2006 7:29:00 PM

0

Geoff Hulette wrote:
> I am having a problem getting gems configured properly on my Mac (OS X
> 10.4.7), hopefully someone here can help me out. I installed ruby and
> ruby gems using the instructions at
> http://hivelogic.com/articles/2005/12/01/ruby_rails_lighttpd_m....
> I am trying to use the XmlSimple gem, but Ruby can't seem to find it, or
> any other gems. I did
>
> $ sudo gem install xml-simple
>
> which seemed to work fine. but then
>
> $ ruby -e "require 'xmlsimple'"
> -e:1:in `require': no such file to load -- xmlsimple (LoadError)
> from -e:1

Rubygems is not loaded with your program. There several ways to
accomplish this. This URL will help:
http://docs.rubygems.org/read/chapte....

In a nutshell, you should be able to do this:

$ ruby -e "require 'rubygems'; require 'xmlsimple'"

-- Jim Weirich

--
Posted via http://www.ruby-....

Geoff Hulette

8/12/2006 7:44:00 PM

0

>> $ ruby -e "require 'xmlsimple'"
>> -e:1:in `require': no such file to load -- xmlsimple (LoadError)
>> from -e:1
>
> Rubygems is not loaded with your program. There several ways to
> accomplish this. This URL will help:
> http://docs.rubygems.org/read/chapte....
>
> In a nutshell, you should be able to do this:
>
> $ ruby -e "require 'rubygems'; require 'xmlsimple'"
>
> -- Jim Weirich

That works, thanks!
-geoff

--
Posted via http://www.ruby-....

darren kirby

8/12/2006 8:34:00 PM

0

quoth the lists:
> Try this:
>
> ruby -e "require 'rubygems'; require 'xml-simple'"
>
> You have to require rubygems first.
>
> -Ryan

Sorry to hijack here, but this is an issue that has sort of unsettled me as I
have seen it come up on this list a few times. Perhaps I am not understanding
gems fully here, but what if you are writing software to be released to the
public that relies on a 3rd party library?

Some might have the lib installed from gems and some might have installed
manually or whatever ... so how do you reconcile the two if you must require
rubygems to use gem installed libs? Why is the gems directory not added to
the regular include path? Are you required to write code to deal with this?
How do experienced Ruby devs deal with this issue? Or am I just thick and it
isn't an issue at all?

any insight appreciated,

-d
--
darren kirby :: Part of the problem since 1976 :: http://badco...
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972

Tilman Sauerbeck

8/12/2006 8:41:00 PM

0

darren kirby [2006-08-13 05:34]:
> quoth the lists:
> > Try this:
> >
> > ruby -e "require 'rubygems'; require 'xml-simple'"
> >
> > You have to require rubygems first.
>
> Sorry to hijack here, but this is an issue that has sort of unsettled me as I
> have seen it come up on this list a few times. Perhaps I am not understanding
> gems fully here, but what if you are writing software to be released to the
> public that relies on a 3rd party library?
>
> Some might have the lib installed from gems and some might have installed
> manually or whatever ... so how do you reconcile the two if you must require
> rubygems to use gem installed libs? Why is the gems directory not added to
> the regular include path? Are you required to write code to deal with this?
> How do experienced Ruby devs deal with this issue? Or am I just thick and it
> isn't an issue at all?
>
> any insight appreciated,

export RUBYOPT=rubygems

The you can use "require" to load both gem-libraries and
non-gem-libraries.

Regards,
Tilman

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

darren kirby

8/12/2006 8:51:00 PM

0

quoth the Tilman Sauerbeck:
<snip>
> export RUBYOPT=rubygems
>
> The you can use "require" to load both gem-libraries and
> non-gem-libraries.
>
> Regards,
> Tilman

Thanks Tilman,
That's what I was looking for...

-d
--
darren kirby :: Part of the problem since 1976 :: http://badco...
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972

Matt Todd

8/13/2006 1:56:00 AM

0

You can also do

ruby -rrubygems -e "require 'xmlsimple'"

which will "require 'rubygems'" for you (because of the "-rrubygems").
Read up on -r if it doesn't click for you.

Cheers,

M.T.

khaines

8/13/2006 3:05:00 PM

0

Tilman Sauerbeck

8/13/2006 4:11:00 PM

0

khaines@enigo.com [2006-08-14 00:04]:
> On Sun, 13 Aug 2006, Tilman Sauerbeck wrote:
>
> >>Some might have the lib installed from gems and some might have installed
> >>manually or whatever ... so how do you reconcile the two if you must
> >>require
> >>rubygems to use gem installed libs? Why is the gems directory not added to
> >>the regular include path? Are you required to write code to deal with
> >>this?
> >>How do experienced Ruby devs deal with this issue? Or am I just thick and
> >>it
> >>isn't an issue at all?
> >>
> >>any insight appreciated,
> >
> >export RUBYOPT=rubygems
>
> Of course, this isn't such a great solution from inside a library,
> However, it's not too hard.

If you are the author of some library:

cat <<EOF >>README
If you're using rubygems, please export RUBYOPT=rubygems.
EOF

Done.

Regards,
Tilman

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?