Rubygems on Mac OS X

G

Geoff Hulette

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_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.rubyforge.org

Thanks in advance!
-geoff
 
L

lists

Try this:

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

You have to require rubygems first.

-Ryan
 
C

Chris Gehlker

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

Jim Weirich

Geoff said:
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_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

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

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

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

-- Jim Weirich
 
D

darren kirby

--nextPart1278567.L00Fz5TxOp
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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=20
have seen it come up on this list a few times. Perhaps I am not understandi=
ng=20
gems fully here, but what if you are writing software to be released to the=
=20
public that relies on a 3rd party library?

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

any insight appreciated,

=2Dd
=2D-=20
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
=2D Dennis Ritchie and Ken Thompson, June 1972

--nextPart1278567.L00Fz5TxOp
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (GNU/Linux)

iD8DBQBE3jsdwPD5Cr/3CJgRAtDMAJ0Yuc7JvO2/spdduPWsaHEjhCE5XwCghvbm
WTZ5R3Rk90xDX4Pz8v5BmUE=
=6/PP
-----END PGP SIGNATURE-----

--nextPart1278567.L00Fz5TxOp--
 
T

Tilman Sauerbeck

--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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

export RUBYOPT=3Drubygems

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

Regards,
Tilman

--=20
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?

--J2SCkAp4GZ/dPZZf
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFE3jzW27uLisrW2w8RAmqDAJ9ejKrk0EM9jrsYqUPwBmFnT/AAOQCfWGMc
2Rz9QIVwsZ1skPLXXdIYm7A=
=Wfni
-----END PGP SIGNATURE-----

--J2SCkAp4GZ/dPZZf--
 
D

darren kirby

--nextPart24597753.xCvFKDy804
Content-Type: text/plain;
charset="iso-8859-6"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

quoth the Tilman Sauerbeck:
export RUBYOPT=3Drubygems

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

=2Dd
=2D-=20
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
=2D Dennis Ritchie and Ken Thompson, June 1972

--nextPart24597753.xCvFKDy804
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (GNU/Linux)

iD8DBQBE3j8awPD5Cr/3CJgRAnigAKDBsbslakIME8Mze5QOslrGlk93TgCg8jOt
hwQe8OCeFdU8oxcNHARiS5c=
=B7xy
-----END PGP SIGNATURE-----

--nextPart24597753.xCvFKDy804--
 
M

Matt Todd

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

khaines

export RUBYOPT=rubygems

Of course, this isn't such a great solution from inside a library,
However, it's not too hard.

begin
require 'rubygems'
rescue LoadError
end
 
T

Tilman Sauerbeck

--RnlQjJ0d97Da+TV1
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

(e-mail address removed) [2006-08-14 00:04]:
On Sun, 13 Aug 2006, Tilman Sauerbeck wrote:
=20
=20
Of course, this isn't such a great solution from inside a library,=20
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=3Drubygems.
EOF

Done.

Regards,
Tilman

--=20
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?

--RnlQjJ0d97Da+TV1
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFE308c27uLisrW2w8RAhkKAJ9IIJaM9CzSk0hh8cII+jVczluWBQCfQyXu
2CX+cpOGl8zi5c9PH4BcTUg=
=/8X1
-----END PGP SIGNATURE-----

--RnlQjJ0d97Da+TV1--
 
D

darren kirby

--nextPart4903046.zV0QukssDo
Content-Type: text/plain;
charset="iso-8859-6"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

quoth the Tilman Sauerbeck:
If you are the author of some library:

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

Done.

I guess it would be bad form to go setting env variables on someone's syste=
m=20
from within a lib...=20

So you could do:

begin
require 'rubygems'
rescue LoadError
end
require 'libfoo'

And it would load 'libfoo' either through gems, if present, or regularly if=
=20
not? Is that right?
Regards,
Tilman

=2Dd
=2D-=20
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
=2D Dennis Ritchie and Ken Thompson, June 1972

--nextPart4903046.zV0QukssDo
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (GNU/Linux)

iD8DBQBE35IFwPD5Cr/3CJgRApwBAJ9iw5igxI2FRAWVzkq8wQGzPXEu3wCggI0A
sVKQhCSty2yrj5IpSC4boB4=
=Sg/N
-----END PGP SIGNATURE-----

--nextPart4903046.zV0QukssDo--
 
T

Tilman Sauerbeck

--PNTmBPCT7hxwcZjr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

darren kirby [2006-08-14 05:57]:
quoth the Tilman Sauerbeck:
=20
I guess it would be bad form to go setting env variables on someone's sys= tem=20
from within a lib...=20

Of course. That's why you would tell your fellow users to please export
RUBYOPT=3Drubygems. So you don't have to change your code.

I'm sure this is documented somewhere, too.

Regards,
Tilman

--=20
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?

--PNTmBPCT7hxwcZjr
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFE35Xk27uLisrW2w8RApQbAJwMrHL/KSdlFQfvwbR0QC2AGv6CDwCfeuG2
fRCtGNSN8lOsYEQ1OuVBrZk=
=jnbp
-----END PGP SIGNATURE-----

--PNTmBPCT7hxwcZjr--
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top