From: Roger Pack on 28 Jul 2010 09:11 Hassan Schroeder wrote: > Is there a way to tell from within a program which executable is being > used -- which executable, not the version -- to run it? os gem: >> require 'os' >> OS.ruby_bin => "c:/installs/ruby192-rc1/bin/ruby.exe" Or require 'rubygems' Gem.ruby I believe. Or apparently ENV['_'] thanks Caleb. -r -r -- Posted via http://www.ruby-forum.com/.
From: Joseph E. Savard on 28 Jul 2010 10:13 Maybe Well it works in an ruby prog. It maybe it truly is MRI issue. Seee if I can fire up j/iron ruby args.rb below: ================== require "rbconfig" puts "The name of the progrma laucnhed is #{$0} OR #{$PROGRAM_NAME}" ARGV.each do|a| puts "Argument: #{a}" end puts "And finally the ruby executable #{ENV['_']}" puts File.join(Config::CONFIG["bindir"],Config::CONFIG["ruby_install_name"]) ================ > From: Hassan Schroeder <hassan.schroeder(a)gmail.com> > Reply-To: <ruby-talk(a)ruby-lang.org> > Date: Wed, 28 Jul 2010 07:30:25 +0900 > To: ruby-talk ML <ruby-talk(a)ruby-lang.org> > Subject: Re: Which Ruby is in use? > > On Tue, Jul 27, 2010 at 3:10 PM, Joel VanderWerf > <joelvanderwerf(a)gmail.com> wrote: > >> Maybe this will work? >> >>>> File.join *Config::CONFIG.values_at("bindir", "ruby_install_name") >> => "/usr/local/bin/ruby" > > Works in a Rails console, but not a Ruby program. But thanks, now > that I consider it I should be able to work with that :-) > > -- > Hassan Schroeder ------------------------ hassan.schroeder(a)gmail.com > twitter: @hassan >
From: Joseph E. Savard on 28 Jul 2010 10:14 You forgot to require "rbconfig" ruby -v -rrbconfig > From: Hassan Schroeder <hassan.schroeder(a)gmail.com> > Reply-To: <ruby-talk(a)ruby-lang.org> > Date: Wed, 28 Jul 2010 08:22:42 +0900 > To: ruby-talk ML <ruby-talk(a)ruby-lang.org> > Subject: Re: Which Ruby is in use? > > On Tue, Jul 27, 2010 at 3:52 PM, Joel VanderWerf > <joelvanderwerf(a)gmail.com> wrote: > >>>>>> File.join *Config::CONFIG.values_at("bindir", "ruby_install_name") >>>> >>>> => "/usr/local/bin/ruby" >>> >>> Works in a Rails console, but not a Ruby program. But thanks, now >>> that I consider it I should be able to work with that :-) >> >> Hm, that's surprising. I tested it in ruby and jruby programs. What's the >> problem? > > ripple:~$ cat foo.rb > puts File.join *Config::CONFIG.values_at("bindir", "ruby_install_name") > ripple:~$ ruby foo.rb > foo.rb:1: uninitialized constant Config (NameError) > ripple:~$ jruby foo.rb > foo.rb:1: uninitialized constant Config (NameError) > ripple:~$ > > -- > Hassan Schroeder ------------------------ hassan.schroeder(a)gmail.com > twitter: @hassan >
From: Hassan Schroeder on 28 Jul 2010 10:42 On Tue, Jul 27, 2010 at 11:41 PM, Caleb Clausen <vikkous(a)gmail.com> wrote: > Hassan, what is you objection to using rbconfig.rb as Joel suggests? > AFAIK, that's the best (only real) solution to this particular > problem. Yeah, that's the pick of the litter. I was looking for the minimal solution and it seemed unDRY to have to require that everywhere I might need the information, but -- undercaffeinated premature optimization aside -- since my real current use case only requires patching one (Rails app) plugin it's fine. I haven't checked yet whether there's a bug filed against JRuby for the lack of support for ENV['_'], which obviously wins the minimalist contest :-) Thanks everyone for the suggestions! -- Hassan Schroeder ------------------------ hassan.schroeder(a)gmail.com twitter: @hassan
From: Roger Pack on 28 Jul 2010 11:16 > I haven't checked yet whether there's a bug filed against JRuby for > the lack of support for ENV['_'], which obviously wins the minimalist > contest :-) ENV['_'] doesn't seem to work for me on windows at all: >> ENV['_'] => nil Thought it might still be a bug in jruby that it not have one under linux, I'm not entirely sure. -r -- Posted via http://www.ruby-forum.com/.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: In Ruby 1.9 Test::Unit::TestCase parse ARGV differently Next: Chat client |