Rbconfig suggestion: ruby_apps

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.

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

						matz.
···

In message “rbconfig suggestion: ruby_apps” on 03/12/09, Joel VanderWerf vjoel@PATH.Berkeley.EDU 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.

Yukihiro Matsumoto wrote:

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.

:slight_smile: 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

···

In message “rbconfig suggestion: ruby_apps” > on 03/12/09, Joel VanderWerf vjoel@PATH.Berkeley.EDU writes:

Hi,

···

In message “Re: rbconfig suggestion: ruby_apps” on 03/12/09, Joel VanderWerf vjoel@PATH.Berkeley.EDU 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.