rbconfig suggestion: ruby_apps

Discussion in 'Ruby' started by Joel VanderWerf, Dec 8, 2003.

  1. Now that there are several new apps (testrb, rdoc) distributed with ruby
    and installed to bindir, it would be convenient to know what they are,
    through some API. Could we have something like

    CONFIG["ruby_apps"] = "ruby irb erb testrb rdoc"

    Or maybe the key should be "ruby_exes".

    My particular reason is for a script that switches symlinks from
    ruby->ruby-1.7.3 to ruby->1.8.1p3 and so on.
    Joel VanderWerf, Dec 8, 2003
    #1
    1. Advertising

  2. In message "rbconfig suggestion: ruby_apps"
    on 03/12/09, Joel VanderWerf <> writes:

    |My particular reason is for a script that switches symlinks from
    |ruby->ruby-1.7.3 to ruby->1.8.1p3 and so on.

    ./configure --program-suffix=-1.8.1p3 will do.

    matz.
    Yukihiro Matsumoto, Dec 9, 2003
    #2
    1. Advertising

  3. Yukihiro Matsumoto wrote:
    > In message "rbconfig suggestion: ruby_apps"
    > on 03/12/09, Joel VanderWerf <> writes:
    >
    > |My particular reason is for a script that switches symlinks from
    > |ruby->ruby-1.7.3 to ruby->1.8.1p3 and so on.
    >
    > ./configure --program-suffix=-1.8.1p3 will do.
    >
    > matz.


    :) That's exactly what I do whenever a new snapshot comes out. Then
    with my little "switchruby" script I can change what my symlinks named
    ruby, irb, and so on point to. And change back again. Sample session:

    # switchruby 1.7.3
    ruby -> ruby-1.7.3
    irb -> irb-1.7.3
    erb -> erb-1.7.3
    # switchruby
    Current versions are:
    ruby -> ruby-1.7.3
    irb -> irb-1.7.3
    erb -> erb-1.7.3
    rdoc -> rdoc-1.8.1p3
    testrb -> testrb-1.8.1p3
    Choices are: 1.7.3 1.8.0 1.8.1-22Nov03 1.8.1p3
    # switchruby 1.8.1p3
    ruby -> ruby-1.8.1p3
    irb -> irb-1.8.1p3
    erb -> erb-1.8.1p3
    rdoc -> rdoc-1.8.1p3
    testrb -> testrb-1.8.1p3

    Of course, switching to 1.8.0 doesn't work so well because:

    # ruby -r rbconfig -e 1
    /usr/local/lib/ruby/1.8/i686-linux/rbconfig.rb:7: ruby lib version
    (1.8.1) doesn't match executable version (1.8.0) (RuntimeError)

    I guess I could swap the lib dirs as well, but that's getting to be too
    much work, and besides I'm really more interested in switching between
    different previews or cvs of the same "teeny" version.

    == switchruby ==

    #!/usr/local/bin/ruby-1.7.3

    require 'rbconfig'

    ext = ARGV[0]

    Dir.chdir Config::CONFIG["bindir"]

    exts = []
    Dir["ruby*"].grep(/^ruby-(.*)/) { |f| exts << $1 }

    ruby_apps = ["ruby", "irb", "erb", "rdoc", "testrb"]
    # this should be provided by rbconfig.rb

    if ext
    unless exts.include? ext
    $stderr.puts "Choices are: #{exts.join(" ")}"
    exit -1
    end

    extstr = ext.sub(/^(?!-)/, "-")

    ruby_apps.each do |app|
    target = app + extstr
    if File.exist? target
    if File.exist?(app) and not File.symlink?(app)
    $stderr.puts "File #{app} exists and is not a symlink. Aborting."
    exit -1
    end
    File.delete(app) and File.symlink(target, app) and
    puts "#{app} -> #{target}"
    end
    end

    else

    cur =
    ruby_apps.map do |app|
    " " + `ls -l #{app}`[/\w+ -> .*/]
    end

    puts "Current versions are:", cur

    puts "Choices are: #{exts.join(" ")}"

    end
    Joel VanderWerf, Dec 9, 2003
    #3
  4. Hi,

    In message "Re: rbconfig suggestion: ruby_apps"
    on 03/12/09, Joel VanderWerf <> writes:

    |Of course, switching to 1.8.0 doesn't work so well because:
    |
    |# ruby -r rbconfig -e 1
    |/usr/local/lib/ruby/1.8/i686-linux/rbconfig.rb:7: ruby lib version
    |(1.8.1) doesn't match executable version (1.8.0) (RuntimeError)

    This suggest me something. But not in the very near future.
    Thanks anyway.

    matz.
    Yukihiro Matsumoto, Dec 9, 2003
    #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. Oliver Obst
    Replies:
    4
    Views:
    107
    Oliver Obst
    Sep 29, 2003
  2. Gavin Sinclair
    Replies:
    7
    Views:
    124
    Gavin Sinclair
    Oct 1, 2003
  3. Jeff Mitchell

    rbconfig / libpathflag is wrong

    Jeff Mitchell, Jun 25, 2004, in forum: Ruby
    Replies:
    0
    Views:
    94
    Jeff Mitchell
    Jun 25, 2004
  4. Glenn M. Lewis

    rbconfig.rb problems

    Glenn M. Lewis, Oct 7, 2004, in forum: Ruby
    Replies:
    2
    Views:
    183
    Paul Brannan
    Oct 8, 2004
  5. chris

    rbconfig (LoadError)

    chris, Mar 6, 2007, in forum: Ruby
    Replies:
    8
    Views:
    285
    chris
    Mar 6, 2007
Loading...

Share This Page