I'm a 34'ish year old web application developer from South Portland, Maine. I love meeting fellow techies, drop me a line if you want to talk shop.
Posted on 11/28 at 05:55 PM
While running a Rails app in Mongrel today, I noticed some application warnings in my logs. The following 2 lines would appear for every page request.
/etc/irbrc:14: warning: already initialized constant HISTFILE
/etc/irbrc:15: warning: already initialized constant MAXHISTSIZE
After doing some homework, I found a fix!
This link (discuss.joyent.com) offered a solution. Just create a file in ~/.irbrc with the following contents:
require 'irb/completion'
require 'irb/ext/save-history'
ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
... and then reboot your server. The warnings should disappear
I came here after a google search on “already initialized constant HISTFILE”. I had just upgraded to Leopard and started seeing them. After re-installing the mongrel gem, it went away. Go figure.
Oops didn’t fix the problem.
I can recommend this solution 100%, haven’t had problems since, let me know if you need help
Works great, thanks a ton!
Often times I will release code for free or go that extra distance to help others online. If my skills were useful to you, please consider a small donation. Thank you very much.
Foundation's Edge, RJones Family, We're Not.com (only for staging), Ailee Jones (same as rjones for now)
Aaron, Barnaby, Brian, Chris, Dirk, Frank, Fred, Four, Justin, Matt, Mike, Monty, Paul, Sean, Travis
I can usually be found lounging on irc.freenode.net while I work, on the following channels: #fauna, #github, #hello-heroku, #jquery, #passenger, #ruby, #rubyonrails, #slicehost, #sproutcore, #textmate, #werenot.
Me again, I actually found a neat article recently I thought I might append to this post: my-irbrc. In addition to fixing the log warnings i described earlier, it also helps customize your console prompt to include your project name!!
require 'irb/completion'
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
IRB.conf[:PROMPT_MODE] = :SIMPLE
# Just for Rails...
if rails_env = ENV['RAILS_ENV']
rails_root = File.basename(Dir.pwd)
IRB.conf[:PROMPT] ||= {}
IRB.conf[:PROMPT][:RAILS] = {
:PROMPT_I => "#{rails_root}> ",
:PROMPT_S => "#{rails_root}* ",
:PROMPT_C => "#{rails_root}? ",
:RETURN => "=> %s\n"
}
IRB.conf[:PROMPT_MODE] = :RAILS
# Called after the irb session is initialized and Rails has
# been loaded (props: Mike Clark).
IRB.conf[:IRB_RC] = Proc.new do
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.instance_eval { alias :[] :find }
end
end