Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Unintentional hype of Ruby irb and ri

Reply
Thread Tools

Unintentional hype of Ruby irb and ri

 
 
stephen.tashiro@us.army.mil
Guest
Posts: n/a
 
      03-30-2006
Perhaps an inflamatory title - but it answers some simple questions.

Having looked at the Pixaxe book and visited various websites with Ruby
tutorials, I think there is an unintentional hype of certain Ruby
features. We may blame this on the distributors of software. For
example, the authors tell us how easy it is to use irb. On my Redhat
Enterprise Linux machine, ruby puts("Hello World") ran fine. But irb
was not a command known to bash. The redhat distribution has the
packages:
ruby-docs-1.8.1-7.EL4.2
ruby-tcltk-1.8.1-7.EL4.2
ruby-1.8.1-7.EL4.2
ruby-mode-1.8.1-7.EL4.2
ruby-devel-1.8.1-7.EL4.2
ruby-libs-1.8.1-7.EL4.2
irb-1.8.1-7.EL4.2
So you might get ruby but not irb.

The authors extol the virtues of ri. I found that ri File (or ri
almost anything) gave:
No ri documentation found in:
/usr/share/ri/1.8/system
/usr/share/ri/1.8/site
/root/.rdoc

These problems can be blamed on incompetent packaging or installation
of Ruby, but it seems to me that the authors of Ruby tutorials should
warn their readers about such problems and perhaps give some hints
about how to resolve them.

In Redhat Enterprise Linux 4, I was able to resolve the irb problem
simply by installing the irb-1.8.1-7 package.

At to the ri problem,I found no tutorials that mention rdoc or
configure ri. Reading the output of
ri -h
I concluded it would suffice to run
rdoc --ri
which creates a director called "doc" in my home directory. And this
makes ri work for the basic ruby objects. (Of course a more efficient
way on a mult-user system would be to create this "doc" file in only
one location and direct the ri for each user to it. It would be nice
to have a simple example of this. )

 
Reply With Quote
 
 
 
 
ara.t.howard@noaa.gov
Guest
Posts: n/a
 
      03-30-2006
On Fri, 31 Mar 2006 http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> Perhaps an inflamatory title - but it answers some simple questions.
>
> Having looked at the Pixaxe book and visited various websites with Ruby
> tutorials, I think there is an unintentional hype of certain Ruby
> features. We may blame this on the distributors of software. For
> example, the authors tell us how easy it is to use irb. On my Redhat
> Enterprise Linux machine, ruby puts("Hello World") ran fine. But irb
> was not a command known to bash. The redhat distribution has the
> packages:
> ruby-docs-1.8.1-7.EL4.2
> ruby-tcltk-1.8.1-7.EL4.2
> ruby-1.8.1-7.EL4.2
> ruby-mode-1.8.1-7.EL4.2
> ruby-devel-1.8.1-7.EL4.2
> ruby-libs-1.8.1-7.EL4.2
> irb-1.8.1-7.EL4.2
> So you might get ruby but not irb.
>
> The authors extol the virtues of ri. I found that ri File (or ri
> almost anything) gave:
> No ri documentation found in:
> /usr/share/ri/1.8/system
> /usr/share/ri/1.8/site
> /root/.rdoc
>
> These problems can be blamed on incompetent packaging or installation
> of Ruby, but it seems to me that the authors of Ruby tutorials should
> warn their readers about such problems and perhaps give some hints
> about how to resolve them.
>
> In Redhat Enterprise Linux 4, I was able to resolve the irb problem
> simply by installing the irb-1.8.1-7 package.
>
> At to the ri problem,I found no tutorials that mention rdoc or
> configure ri. Reading the output of
> ri -h
> I concluded it would suffice to run
> rdoc --ri
> which creates a director called "doc" in my home directory. And this
> makes ri work for the basic ruby objects. (Of course a more efficient
> way on a mult-user system would be to create this "doc" file in only
> one location and direct the ri for each user to it. It would be nice
> to have a simple example of this. )


we use rhe on all our machines and i can tell you this: the rh ruby rpms are
broken, broken, broken, broken - do not use them and please complain to redhat
(i have several times).

all the issues you are seeing are resolved by using almost any installation
method besides rhe rpms. it even works on fedora.

i manage about 50 machines and we've taken the compile route - however, since
all the boxes see a common nfs mount we install only once there.

rhe rpms are really really bad in general and should be avoided - for example
the image magic packages break (silently) loseless compression of jp2s... the
perl rpm has a userland kernel panic causing bug, etc, etc.

we use plain vanilla rhe, installing anything 'important' via compilation and
have 100% success with this approach. it's also immune to the auto-upgrade of
enterprise systems breaking 24x7 systems on a late sunday evening.

the reality is that there is exactly one method of installing ruby, or
anything else for that matter, that will work on any platform:

./configure --prefix=dst && make && sudo make install

this becomes __really__ important once one starts installing gems that
auto-compile and then upgrade ruby using rpms - only to have all gems start
giving bus errors... correct compilation avoids this entirely in addition to
allowing multiple ruby versions to be installed (which we require).

sad. but true.

regards.

-a
--
share your knowledge. it's a way to achieve immortality.
- h.h. the 14th dali lama


 
Reply With Quote
 
 
 
 
Hans Fugal
Guest
Posts: n/a
 
      03-30-2006

(E-Mail Removed) wrote:
> we use rhe on all our machines and i can tell you this: the rh ruby
> rpms are
> broken, broken, broken, broken - do not use them and please complain to
> redhat
> (i have several times).
>
> all the issues you are seeing are resolved by using almost any installation
> method besides rhe rpms. it even works on fedora.
>
> i manage about 50 machines and we've taken the compile route - however,
> since
> all the boxes see a common nfs mount we install only once there.
>
> rhe rpms are really really bad in general and should be avoided - for
> example
> the image magic packages break (silently) loseless compression of
> jp2s... the
> perl rpm has a userland kernel panic causing bug, etc, etc.
>
> we use plain vanilla rhe, installing anything 'important' via
> compilation and
> have 100% success with this approach. it's also immune to the
> auto-upgrade of
> enterprise systems breaking 24x7 systems on a late sunday evening.
>
> the reality is that there is exactly one method of installing ruby, or
> anything else for that matter, that will work on any platform:
>
> ./configure --prefix=dst && make && sudo make install
>
> this becomes __really__ important once one starts installing gems that
> auto-compile and then upgrade ruby using rpms - only to have all gems start
> giving bus errors... correct compilation avoids this entirely in
> addition to
> allowing multiple ruby versions to be installed (which we require).
>
> sad. but true.


I can second that. I have never worked with a more frustrating
distribution than R_HEL_ (emphasis added).
 
Reply With Quote
 
Randy Kramer
Guest
Posts: n/a
 
      03-30-2006
On Thursday 30 March 2006 12:59 pm, (E-Mail Removed) wrote:
> i manage about 50 machines and we've taken the compile route - however,
> since all the boxes see a common nfs mount we install only once there.


Hmm, interesting idea--tell me more:

* Is that partition mounted as one of the standard partitions (/usr...) or
something else?

* Do you have to do anything on each of those 50 machines, or just mount
the NFS partition--hmm, I guess you'd at least have to add something to the
PATH of each user (at least, if a non-standard partition)?

I might try this, or even on a local non-standard partition (I guess I just
have to set the prefix appropriately).

This might solve some problems for me--I'm trying to get TkHTML working for
me, and by now I'm concerned that I've tried so many things I've created more
problems for myself--I could start completely over on a new partition.

Then I guess I'd have to do the ./configure --prefix=dst && make && sudo make
install process for:

Ruby
tcltk (or ActiveTcl)
TkHTML (although in reading the instructions for this I realize there are some
special things to deal with, like the "parallel" bld directory)

More info:

Part of my problem is that I've compiled Ruby, then installed ActiveTcl, and I
don't know how to uninstall something that I installed by compiling.
ActiveTcl seemed to have an uninstall.tcl script, but that failed for me. I
guess I'll just go around and delete all files and directories that look like
they have anything to do with Ruby, tcltk, ActiveTcl, or TkHTML, and then
start over.

This is on a Mandriva2006 system. I don't know whether the rpms on Mandriva
are to blame in any way--I suspect most of the problem(s) are just my
ignorance/inexperience in setting something like this up.

Randy Kramer



 
Reply With Quote
 
ara.t.howard@noaa.gov
Guest
Posts: n/a
 
      03-30-2006
On Fri, 31 Mar 2006, Randy Kramer wrote:

> On Thursday 30 March 2006 12:59 pm, (E-Mail Removed) wrote:
>> i manage about 50 machines and we've taken the compile route - however,
>> since all the boxes see a common nfs mount we install only once there.

>
> Hmm, interesting idea--tell me more:
>
> * Is that partition mounted as one of the standard partitions (/usr...) or
> something else?


something else = prefix=/dmsp/reference/

we have tons of stuff living there

> * Do you have to do anything on each of those 50 machines, or just mount
> the NFS partition--hmm, I guess you'd at least have to add something to the
> PATH of each user (at least, if a non-standard partition)?


yes. PATH must be set. this is done in /etc/profile.d/dmsp.sh. we also set
LD_LIBRARY_PATH here - thought this needed be done (see below)

> I might try this, or even on a local non-standard partition (I guess I just
> have to set the prefix appropriately).
>
> This might solve some problems for me--I'm trying to get TkHTML working for
> me, and by now I'm concerned that I've tried so many things I've created more
> problems for myself--I could start completely over on a new partition.


exactly one of the issues i had! i have tcl/tk compiled and installed this
way too.

> Then I guess I'd have to do the ./configure --prefix=dst && make && sudo make
> install process for:
>
> Ruby
> tcltk (or ActiveTcl)
> TkHTML (although in reading the instructions for this I realize there are some
> special things to deal with, like the "parallel" bld directory)


yup.

> More info:
>
> Part of my problem is that I've compiled Ruby, then installed ActiveTcl, and I
> don't know how to uninstall something that I installed by compiling.
> ActiveTcl seemed to have an uninstall.tcl script, but that failed for me. I
> guess I'll just go around and delete all files and directories that look like
> they have anything to do with Ruby, tcltk, ActiveTcl, or TkHTML, and then
> start over.
>
> This is on a Mandriva2006 system. I don't know whether the rpms on Mandriva
> are to blame in any way--I suspect most of the problem(s) are just my
> ignorance/inexperience in setting something like this up.


if you follow these steps just about anything will work:

- chose a common nfs location. we'll call it /nfs

- every single time you compile something do this

export LD_RUN_PATH=/nfs/lib
export LD_LIBRARY_PATH=/nfs/lib
./configure --prefix=/nfs && make && make install

i set LD_LIBRARY_PATH and LD_RUN_PATH in my .bashrc because i do this so
much. the cool thing with LD_RUN_PATH is that it __encodes__
inter-library dependancies (so ruby tk.so needs libtk.so needs ...) such
that users do not need to set LD_LIBRARY_PATH themselves. of course they
may, but they do not have to

- all users of code on this partiion need only do

export PATH=/nfs/bin:$PATH

i have a /nfs/build and /nfs/packages - you can guess what these are for
if you like this approach you may want to check out gnu stowe. i find it easy
enough to do by hand though...

regards.

-a
--
share your knowledge. it's a way to achieve immortality.
- h.h. the 14th dali lama


 
Reply With Quote
 
stephen.tashiro@us.army.mil
Guest
Posts: n/a
 
      03-30-2006
I tried the suggestion of installing from source and I like the result
better. (My suggestion to run rdoc --ri is only useful if you run it
in some directory whose tree contains the source code (*.c) files for
Ruby. ) After an install from source with
../configure
make
su
make install

The ri and irb commands work fine. But when I try to use FxRuby, the
extension for the Fox Gui Toolkit, there are problems. The extension
wants the library libruby.so, which is missing. I tried

make distclean
../configure --enable-shared --enable-install-doc --enable-pthread
(As if I really knew what I was doing !)
make
make install-all

Then I had a libruby.so and ruby, irb and ri still worked.

However the elementary test
irb> require 'fox14'
fails since it cannot find the files fox14/core.rb and fox14/core.so.
An strace of this process shows it is looking in the correct path for
the files. (I resorted to running irb in the fox14 directory.) The
problem is that the files were not produced when I compiled fox-1.4.32.

I'll be delighted if someone can tell me the answer to that problem.
However to return to generalities: I think people trying to use Ruby
face more of a challenge than Perl and Python users since they are less
likely to find Ruby installed and ready-to-go. In the current epoch,
writers of tutorials would do better to give detailed coverage of
installation problems. Otherwise the pages about how easy and nice
Ruby is will seem a fraud.

For example, if you read the typical exposition of the
require 'xyz'
"command, it doesn't explain how the name 'xyz' is connected to any
file on the machine. By experiment it seems to search for a directory
named 'xyz'. What paths does it take? What files does it need in that
directory? If everything is perfectly installed you don't have to
worry about this, but in practice you do.

 
Reply With Quote
 
Ryan Allen
Guest
Posts: n/a
 
      03-30-2006
Hi Guys (and Gals!)

This is my first post on the list, so Hello!

Something very strange is happening (as far as I can tell) with a
float comparison; here is the code in question:

("55.59".to_f / 100) == 0.5559 # returns false

However:

"55.59".to_f / 100 # returns Float 0.5559
0.5559 # returns Float 0.5559
0.5559 == 0.5559 # returns true

And more!:

("55.5".to_f / 100) == 0.555 # returns true
("55.53".to_f / 100) == 0.5553 # returns true
("55.56".to_f / 100) == 0.5556 # returns true
("55.58".to_f / 100) == 0.5558 # returns true
("55.59".to_f / 100) == 0.5559 # returns false !!
("44.59".to_f / 100) == 0.4449 # returns true !!
("44.59".to_f / 100) == 0.4449 # returns false !!!!

It doesn't seem to like .59's... What did .59 ever do?

I picked this up while writing a unit test, I've run this code in irb
and I'm not sure what's going on...

Can anyone shed some light on this?

I'm using ruby 1.8.4 (2005-12-24) [powerpc-darwin8.5.0]

Cheers,
Ryan.


 
Reply With Quote
 
Mike Stok
Guest
Posts: n/a
 
      03-31-2006

On 30-Mar-06, at 6:58 PM, Ryan Allen wrote:

> Hi Guys (and Gals!)
>
> This is my first post on the list, so Hello!
>
> Something very strange is happening (as far as I can tell) with a
> float comparison; here is the code in question:
>
> ("55.59".to_f / 100) == 0.5559 # returns false
>
> However:
>
> "55.59".to_f / 100 # returns Float 0.5559
> 0.5559 # returns Float 0.5559
> 0.5559 == 0.5559 # returns true
>
> And more!:
>
> ("55.5".to_f / 100) == 0.555 # returns true
> ("55.53".to_f / 100) == 0.5553 # returns true
> ("55.56".to_f / 100) == 0.5556 # returns true
> ("55.58".to_f / 100) == 0.5558 # returns true
> ("55.59".to_f / 100) == 0.5559 # returns false !!
> ("44.59".to_f / 100) == 0.4449 # returns true !!
> ("44.59".to_f / 100) == 0.4449 # returns false !!!!
>
> It doesn't seem to like .59's... What did .59 ever do?
>
> I picked this up while writing a unit test, I've run this code in
> irb and I'm not sure what's going on...
>
> Can anyone shed some light on this?
>
> I'm using ruby 1.8.4 (2005-12-24) [powerpc-darwin8.5.0]
>
> Cheers,
> Ryan.


You might want to look at http://docs.sun.com/source/806-3568/
ncg_goldberg.html and http://support.microsoft.com/kb/q69333/

ratdog:~ mike$ irb
irb(main):001:0> '%.40f' % 0.5559
=> "0.5558999999999999497291014449729118496180"
irb(main):002:0> '%.40f' % (55.59 / 100)
=> "0.5559000000000000607514039074885658919811"
irb(main):003:0> '%.40f' % ("55.59".to_f / 100)
=> "0.5559000000000000607514039074885658919811"


Mike

--

Mike Stok <(E-Mail Removed)>
http://www.stok.ca/~mike/

The "`Stok' disclaimers" apply.






 
Reply With Quote
 
Matthew Moss
Guest
Posts: n/a
 
      03-31-2006
> ("44.59".to_f / 100) =3D=3D 0.4449 # returns true !!
> ("44.59".to_f / 100) =3D=3D 0.4449 # returns false !!!!


Typos? You typed the same exact line twice and it comes back with two
different answers?

In any case, exact equality comparisons of floating-point numbers is
bad. Don't do it.

Either compare with a small threshold, or deal with rationals.


 
Reply With Quote
 
ara.t.howard@noaa.gov
Guest
Posts: n/a
 
      03-31-2006
On Fri, 31 Mar 2006 (E-Mail Removed) wrote:

> I tried the suggestion of installing from source and I like the result
> better. (My suggestion to run rdoc --ri is only useful if you run it
> in some directory whose tree contains the source code (*.c) files for
> Ruby. ) After an install from source with
> ../configure
> make
> su
> make install


great.

> The ri and irb commands work fine. But when I try to use FxRuby, the
> extension for the Fox Gui Toolkit, there are problems. The extension
> wants the library libruby.so, which is missing. I tried
>
> make distclean
> ../configure --enable-shared --enable-install-doc --enable-pthread
> (As if I really knew what I was doing !)
> make
> make install-all
>
> Then I had a libruby.so and ruby, irb and ri still worked.
>
> However the elementary test
> irb> require 'fox14'
> fails since it cannot find the files fox14/core.rb and fox14/core.so.
> An strace of this process shows it is looking in the correct path for
> the files. (I resorted to running irb in the fox14 directory.) The
> problem is that the files were not produced when I compiled fox-1.4.32.


here is what i think happened (largely guessing):

- you compiled ruby using defaults. this installed into --prefix=/usr/local

see if this is true. if so see what happens why you type

/usr/local/bin/irb

does it work? if so great. note that you still probably have another
ruby and irb in /usr/bin!

- now, rhe is evil and does not look in /usr/local/lib for linking. the way
to handle this is to configure the linker properly. do a 'man ldconfig'
or 'man ld.so' - basically you have to add a line with '/usr/local/lib' to
'/etc/ld.so.conf' and run 'ldconfig'. this just tells the system to look
here for libs. the reason you want to do this is because your libruby.so
is probably in /usr/local/lib/libruby.so now. (is it?)

- here is a totally general way to compile stuff, including stuff that has
mutual dependancies

export prefix=/usr/local/

export LD_LIBRARY_PATH=$prefix/lib

export LD_RUN_PATH=$prefix/lib

export PATH=$prefix/lib

./configure --prefix=$prefix && make && sudo make install

(note: never, never, never compile as root)

if you build ruby this was and then fox all should be well. ping me
offline if you stil have issues. you can probably recover what you have
by setting the right ENV vars - but it may be easier to start over with
ruby first... maybe not.

if you have issues ping me offline so we don't bore everyone...


> I'll be delighted if someone can tell me the answer to that problem.
> However to return to generalities: I think people trying to use Ruby
> face more of a challenge than Perl and Python users since they are less
> likely to find Ruby installed and ready-to-go. In the current epoch,
> writers of tutorials would do better to give detailed coverage of
> installation problems. Otherwise the pages about how easy and nice
> Ruby is will seem a fraud.
>
> For example, if you read the typical exposition of the
> require 'xyz'
> "command, it doesn't explain how the name 'xyz' is connected to any
> file on the machine. By experiment it seems to search for a directory
> named 'xyz'. What paths does it take? What files does it need in that
> directory? If everything is perfectly installed you don't have to
> worry about this, but in practice you do.


true statements all.

like i said before though - the best (but painful) - answer (imho) is to learn
about the compilers and linkers on your system. as lame as this sounds one
can take solace in the fact that it's like learning 'vi' - once you know it
you're set on __any__ *nix system - including macs.

btw. are you a sysad? we sure can't get root on ANY of our systems now
unless one is a sysad...

kind regards.

-a
--
share your knowledge. it's a way to achieve immortality.
- h.h. the 14th dali lama


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
translating Python to Assembler...sorry if this is duplicated...it's unintentional over@thepond.com Python 2 01-23-2008 12:28 PM
Unintentional switching between windows Jim Beaver Computer Support 0 08-26-2006 07:01 PM
[ADV] Shameless Hype for Ruby Stuff Goodness James Britt Ruby 2 02-19-2006 07:13 PM
Unintentional B&W tint ... PcB Digital Photography 21 01-29-2006 04:48 PM
DVD Verdict reviews: AUGUSTUS, PHONE, HYPE, YVES SAINT LAURENT: HIS LIFE AND TIMES/5 AVENUE MARCEAU 75116 PARIS, and more! DVD Verdict DVD Video 0 02-17-2005 10:13 AM



Advertisments