rubygems executables don't seem to work

Ben Woodcroft's Avatar

Ben Woodcroft

06 Jan, 2012 02:20 AM


I'm having a bit of trouble getting executables to work in rubygems. Take for example the gem bio-plasmoap version 0.0.2.

I'm using jeweler here, and my bin directory has this bin/plasmoap.rb script in it (permssions executable). Looking in the generated gemspec I see

s.executables = [%q{plasmoap.rb}]

and there is an executable installed when I install the gem:

$ which plasmoap.rb

However that's not my script, it has been put in place by rubygems

$ cat `which plasmoap.rb`
# This file was generated by RubyGems.
# The application 'bio-plasmoap' is installed as part of a gem, and
# this file is here to facilitate running it.

require 'rubygems'

version = ">= 0"

if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
  version = $1

gem 'bio-plasmoap', version
load Gem.bin_path('bio-plasmoap', 'plasmoap.rb', version)

Which I don't especially find annoying, except that the script doesn't do anything when I run it. It isn't very facilitative!

$ plasmoap.rb
(no output)

One way around this is to specify the script itself, using something like

$ gem contents bio-plasmoap
$ /usr/lib/ruby/gems/1.8/gems/bio-plasmoap-0.0.2/bin/plasmoap.rb
<script executes properly>

I'm using the rubygems 1.8.14, and was able to reproduce the above on ruby 1.9.2 for good measure (with the same version of rubygems).

Thanks - I hope I'm not missing anything obvious here, but this isn't the first time I've come across this so it isn't just an off moment.

  1. Support Staff 1 Posted by Nick Quaranto on 04 Aug, 2012 06:40 PM

    Nick Quaranto's Avatar

    Sorry, this comment was buried in our spam inbox.

    Did you get this figured out?

  2. 2 Posted by donttrustben on 04 Aug, 2012 10:27 PM

    donttrustben's Avatar

    Yes, I did thanks.

    The issue was that I was surrounding my code with this if statement:

    if __FILE__ == $0

    Once that was removed, there was no further issues.

  3. Nick Quaranto closed this discussion on 07 Sep, 2012 03:43 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac