From: Robert Klemme Date: 2009-03-26T16:51:22+09:00 Subject: Re: : HOWTO start irb on a different object 2009/3/25 Jeremy Henty : > On 2009-03-24, Robert Klemme wrote: >> On 24.03.2009 17:25, Jeremy Henty wrote: >>> ... I can put an .irbrc  in my application directory that makes irb >>> start up in the context of an application object. >> >> But wouldn't you have to start irb then with either >> >> HOME=. irb >> >> or with other options in order to make it read the local .irbrc? > > No,  because irb  automatically  looks  for a  .irbrc  in the  current > working directory as well as in $HOME. I tested that but my versions apparently do not: 08:50:08 ~$ cd /tmp 08:50:10 tmp$ echo 'puts 123' > .irbrc 08:50:16 tmp$ irb Ruby version 1.8.7 irb(main):001:0> exit 08:50:24 tmp$ irb19 Ruby version 1.9.1 irb(main):001:0> exit I also checked that there are no errors in my ~/.irbrc 08:50:35 tmp$ ruby19 ~/.irbrc Ruby version 1.9.1 08:50:45 tmp$ cat ~/.irbrc puts "Ruby version #{RUBY_VERSION}" require 'irb/completion' 08:51:29 tmp$ And irb is not aliased 08:52:29 tmp$ type -a irb irb19 irb is /usr/bin/irb irb is /bin/irb irb19 is /opt/bin/irb19 08:53:20 tmp$ What am I missing? >> Btw, if you can make IRB read a "local" .irbrc already, then you can >> as well place code in there like >> >> application = whatever_initialization() >> irb application >> exit > > That doesn't work: "load error: /tmp/user/jeremy/.irbrc NoMethodError: > undefined   method  `irb'  for   main:Object".   Commands   like  "irb > application" only work after  irb starts its read-eval-print loop, and > it does  that *after* it  loads the config  file.  (I agree  that this > trick would make my hack redundant if it did work.) Good point. Kind regards robert -- remember.guy do |as, often| as.you_can - without end