rubygems executables don't seem to work

Ben Woodcroft's Avatar

Ben Woodcroft

06 Jan, 2012 02:20 AM

Hi,

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
/usr/bin/plasmoap.rb

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

$ cat `which plasmoap.rb`
#!/usr/bin/ruby1.8
#
# 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
  ARGV.shift
end

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
...
$ /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.
ben

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

    Once that was removed, there was no further issues.
    Thanks,
    ben

  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

Generic

? 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

Recent Discussions

30 Oct, 2014 04:34 PM
30 Oct, 2014 02:46 PM
28 Oct, 2014 09:51 AM
23 Oct, 2014 05:37 PM
21 Oct, 2014 10:47 AM