# Ruby 1.8.5: cannot use rdoc/usage from a gem executable

**URL:** <https://www.ruby-forum.com/t/ruby-1-8-5-cannot-use-rdoc-usage-from-a-gem-executable/66781>\
**Category:** Ruby\
**Created:** [August 29, 2006, 8:56am UTC](https://www.ruby-forum.com/t/ruby-1-8-5-cannot-use-rdoc-usage-from-a-gem-executable/66781 "2006-08-29T08:56:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suraj\_NSKurapati](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3be4f8/32.png) [@Suraj\_NSKurapati](https://www.ruby-forum.com/u/Suraj_NSKurapati)\
**Post date:** [August 29, 2006, 8:56am UTC](https://www.ruby-forum.com/t/ruby-1-8-5-cannot-use-rdoc-usage-from-a-gem-executable/66781/1 "2006-08-29T08:56:22Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hello,

In Ruby 1.8.5, RDoc::usage\_no\_exit parses usage information from the  
earliest file in the Kernel#caller list. This works well if you directly  
invoke the file containing the usage information.

However, when a Ruby program (containing usage information in the same  
file) is shipped as part of the Gem::Specification#executables array,  
RubyGems creates a proxy for that program in the system bin/ directory.  
Because of the proxy, the Ruby program is not invoked directly, and  
therefore RDoc::usage\_no\_exit is parsing the usage information of the  
proxy!

The way I’ve solved it, for now, is to define a RDoc::usage\_from\_file  
method that parses usage information from a given file, as follows.

$ diff -bc lib/rdoc/usage.rb{.orig,}  
\*\*\* lib/rdoc/usage.rb.orig 2006-08-28 23:39:39.000000000 -0700

- — lib/rdoc/usage.rb 2006-08-28 23:41:41.000000000 -0700

* * *

\*\*\* 97,103 \*\*\*\*  
# Display usage  
def RDoc.usage\_no\_exit(\*args)  
main\_program\_file = caller[-1].sub(/:\d+$/, ‘’)  
! comment = File.open(main\_program\_file) do |file|  
find\_comment(file)  
end

- — 97,108 ----
# Display usage
def RDoc.usage\_no\_exit(\*args)  
main\_program\_file = caller[-1].sub(/:\d+$/, ‘’)  
! usage\_from\_file(main\_program\_file)  
! end  
!  
! # Display usage from the given file  
! def RDoc.usage\_from\_file(input\_file, \*args)  
! comment = File.open(input\_file) do |file|  
find\_comment(file)  
end

Does anyone have other ideas or solutions? Is it too brash to suggest  
that  
such functionality be added to RDoc?

Thanks for your consideration.  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFE8+T5mV9O7RYnKMcRAmzFAJsGZ0RRKII/BqmRh5TBUejmOtrAfACdG7Kz  
o2kBe93ypOFMlSPmGaarGN4=  
=Aycb  
-----END PGP SIGNATURE-----
