gem bin stubs

Discussion in 'Ruby' started by Ara.T.Howard, Oct 27, 2005.

  1. Ara.T.Howard

    Ara.T.Howard Guest

    when you install a program under ./bin/ using rubygems it wrappes the code in
    a stub - something like

    require_gem 'yourapp'
    load 'yourapp'

    this is all well and good - except that it seems redundant in nearly all
    cases. for example my ruby queue package has a program in bin that looks
    something like

    require_gem 'rq'
    RQ::Main::new ARGV, ENV

    if i package this with ruby gems this program with get wrapped to look
    something like

    require_gem 'rq', version
    load 'rq'

    why? i mean - you must code you programs to require any libraries anyhow -
    why would gems wrap these programs by doing the same again? it seems like
    programs in ./bin/ should be installed as is. have i missed something
    critical here?

    regards.

    -a
    --
    ===============================================================================
    | email :: ara [dot] t [dot] howard [at] noaa [dot] gov
    | phone :: 303.497.6469
    | anything that contradicts experience and logic should be abandoned.
    | -- h.h. the 14th dalai lama
    ===============================================================================
    Ara.T.Howard, Oct 27, 2005
    #1
    1. Advertising

  2. Ara.T.Howard

    Eric Hodel Guest

    On Oct 26, 2005, at 6:33 PM, Ara.T.Howard wrote:

    > when you install a program under ./bin/ using rubygems it wrappes
    > the code in
    > a stub


    [...]

    > why? i mean - you must code you programs to require any libraries
    > anyhow -
    > why would gems wrap these programs by doing the same again?


    So you can load version 1.0.0 vs version 2.0.3 (for example).

    wrapped_gem _1.0.0_ rest of args

    is how this is done, I think...

    > it seems like
    > programs in ./bin/ should be installed as is. have i missed something
    > critical here?


    $ gem help install
    Usage: gem install GEMNAME [options]

    Options:
    -v, --version VERSION Specify version of gem to install
    -l, --local Restrict operations to the
    LOCAL domain (default)
    -r, --remote Restrict operations to the
    REMOTE domain
    -b, --both Allow LOCAL and REMOTE operations
    -i, --install-dir DIR
    -d, --[no-]rdoc Generate RDoc documentation for
    the gem on install
    -f, --[no-]force Force gem to install, bypassing
    dependency checks
    -t, --[no-]test Run unit tests prior to
    installation
    -w, --[no-]wrappers Use bin wrappers for executables
    Not available on dosish platforms
    ^^^^^^^^^^^^^^^^^^^

    Courtesy of the first Seattle.rb RubyGems hackfest.

    --
    Eric Hodel - - http://segment7.net
    FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
    Eric Hodel, Oct 27, 2005
    #2
    1. Advertising

  3. Ara.T.Howard

    Ara.T.Howard Guest

    On Thu, 27 Oct 2005, Eric Hodel wrote:

    >> why? i mean - you must code you programs to require any libraries anyhow -
    >> why would gems wrap these programs by doing the same again?

    >
    > So you can load version 1.0.0 vs version 2.0.3 (for example).
    >
    > wrapped_gem _1.0.0_ rest of args
    >
    > is how this is done, I think...


    hmm - i did read the source and see this - i just seems overkill since the app
    itself would do this if it cared... most of my production apps are simple two
    line scripts that just load a lib. but i guess this could come in handy. it
    doesn't seem to work however:

    jib:~ > cat `which foo`
    #!/dmsp/reference/bin/ruby
    #
    # This file was generated by RubyGems.
    #
    # The application 'alib' is installed as part of a gem, and
    # this file is here to facilitate running it.
    #

    require 'rubygems'
    version = "> 0"
    if ARGV.size > 0 && ARGV[0][0]==95 && ARGV[0][-1]==95
    if Gem::Version.correct?(ARGV[0][1..-2])
    version = ARGV[0][1..-2]
    ARGV.shift
    end
    end
    p version
    require_gem 'alib', version
    p ALib::VERSION
    load 'foo'

    jib:~ > foo "_> 1.0_"
    "> 0"
    "0.3.0"
    42

    in otherwords the version argument doesn't seem to be a gem version - but only
    a tripple.

    the correct? method gets called later anyhow - the wrapper should pass any
    predicate through (~>, >=, etc) and blow up later in require_gem rather that
    disallow valid gem versions up front like that.

    in this way you can require a program with a know interface but un-known
    implementation.


    >> it seems like programs in ./bin/ should be installed as is. have i missed
    >> something critical here?

    >
    > $ gem help install
    > Usage: gem install GEMNAME [options]
    >
    > Options:
    > -v, --version VERSION Specify version of gem to install
    > -l, --local Restrict operations to the LOCAL domain
    > (default)
    > -r, --remote Restrict operations to the REMOTE domain
    > -b, --both Allow LOCAL and REMOTE operations
    > -i, --install-dir DIR
    > -d, --[no-]rdoc Generate RDoc documentation for the gem
    > on install
    > -f, --[no-]force Force gem to install, bypassing
    > dependency checks
    > -t, --[no-]test Run unit tests prior to installation
    > -w, --[no-]wrappers Use bin wrappers for executables
    > Not available on dosish platforms
    > ^^^^^^^^^^^^^^^^^^^
    >
    > Courtesy of the first Seattle.rb RubyGems hackfest.


    but that's client side. that means that if i put a /bin/sh script or, worse,
    a.out program into bin and gem it up i'll depend on every client doing this or
    else those programs will be hosed. is there a way to specify this behaviour in
    the spec?


    regards.

    -a
    --
    ===============================================================================
    | email :: ara [dot] t [dot] howard [at] noaa [dot] gov
    | phone :: 303.497.6469
    | anything that contradicts experience and logic should be abandoned.
    | -- h.h. the 14th dalai lama
    ===============================================================================
    Ara.T.Howard, Oct 27, 2005
    #3
  4. Ara.T.Howard

    Eric Hodel Guest

    On Oct 26, 2005, at 7:21 PM, Ara.T.Howard wrote:

    > On Thu, 27 Oct 2005, Eric Hodel wrote:


    >> $ gem help install
    >> Usage: gem install GEMNAME [options]
    >>
    >> Options:

    [...]
    >> -w, --[no-]wrappers Use bin wrappers for executables
    >> Not available on dosish platforms
    >> ^^^^^^^^^^^^^^^^^^^
    >>
    >> Courtesy of the first Seattle.rb RubyGems hackfest.
    >>

    >
    > but that's client side. that means that if i put a /bin/sh script
    > or, worse,
    > a.out program into bin and gem it up i'll depend on every client
    > doing this or
    > else those programs will be hosed. is there a way to specify this
    > behaviour in
    > the spec?


    No. We didn't even think of that.

    --
    Eric Hodel - - http://segment7.net
    FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
    Eric Hodel, Oct 27, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ara.T.Howard
    Replies:
    0
    Views:
    159
    Ara.T.Howard
    Oct 27, 2005
  2. Ara.T.Howard

    gem and stubs

    Ara.T.Howard, Nov 15, 2005, in forum: Ruby
    Replies:
    4
    Views:
    112
    Gavin Sinclair
    Nov 18, 2005
  3. anne001
    Replies:
    1
    Views:
    403
  4. Austin 7873
    Replies:
    5
    Views:
    179
    Eric Hodel
    Jan 27, 2007
  5. James Calfee
    Replies:
    0
    Views:
    145
    James Calfee
    Nov 25, 2009
Loading...

Share This Page