First question from a fundamental level - What is the meaning of an un-initialized constant error in Ruby? I come from an objective-c background, if that helps provide some context.
Secondly, I am running a rake task in rails that is throwing the aforementioned error. Specifically, the error occurs when I am using the 'tor-privoxy' gem, which is a Mechanize wrapper allowing automated browsing through a tor proxy.
I am using the following example code provided on github: https://github.com/pirj/tor-privoxy
agent ||= TorPrivoxy::Agent.new '127.0.0.1', '', {8118 => 9050} do |agent|
sleep 10
puts "New IP is #{agent.ip}"
page = agent.get('https://www.example.com/')
end
>> New IP is 72.141.125.115
>> NameError: uninitialized constant Net::HTTP::Persistent::SSLReuse::HTTPResponse
from /Library/Ruby/Gems/1.8/gems/net-http-persistent-2.3.3/lib/net/http/persistent/ssl_reuse.rb:115:in `connect'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:553:in `do_start'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:548:in `start'
from /Library/Ruby/Gems/1.8/gems/net-http-persistent-2.3.3/lib/net/http/persistent.rb:405:in `connection_for'
from /Library/Ruby/Gems/1.8/gems/net-http-persistent-2.3.3/lib/net/http/persistent.rb:616:in `request'
from /Library/Ruby/Gems/1.8/gems/mechanize-2.1/lib/mechanize/http/agent.rb:264:in `fetch'
from /Library/Ruby/Gems/1.8/gems/mechanize-2.1/lib/mechanize.rb:319:in `get'
from /Library/Ruby/Gems/1.8/gems/tor-privoxy-0.1.1/lib/tor-privoxy/agent.rb:16:in `send'
from /Library/Ruby/Gems/1.8/gems/tor-privoxy-0.1.1/lib/tor-privoxy/agent.rb:16:in `method_missing'
from (irb):4
from /Library/Ruby/Gems/1.8/gems/tor-privoxy-0.1.1/lib/tor-privoxy/agent.rb:11:in `call'
from /Library/Ruby/Gems/1.8/gems/tor-privoxy-0.1.1/lib/tor-privoxy/agent.rb:11:in `initialize'
from (irb):1:in `new'
from (irb):1
On the other hand, if I run this same code in irb, it does not throw the unitialized constant error. I have ensured that my gemfile includes 'tor-privoxy' and ran the 'bundle install' command.
if you want to work with ruby on your mac, i recommend that you use a tool like rvm or rbenv to manage your installation of ruby.
the error that you are experiencing seems to be already known. have a look at this github issue: https://github.com/thrillcall/net-http-persistent/commit/9f770b4660f1c9c433c1f3b50ba24dd4f1f71cf8