Skip to content

Instantly share code, notes, and snippets.

@lietu
Created May 15, 2017 16:09
Show Gist options
  • Save lietu/91c74b1f739a1dea7bdc6978d6e40e41 to your computer and use it in GitHub Desktop.
Save lietu/91c74b1f739a1dea7bdc6978d6e40e41 to your computer and use it in GitHub Desktop.
Reproducible problem with Rubygems when using FREEDOME
# This minimal script seems to reproduce the issue with Rubygems
#
# It seems Ruby DNS resolver does something odd, as when FREEDOME is on, this
# fails with a SocketError, and when FreeDOME is off it fails with a
# Resolv::ResolvError.
#
# This code is built based on Rubygems source code:
# https://github.com/rubygems/rubygems/blob/v2.3.0/lib/rubygems/remote_fetcher.rb#L92-L93
#
# That code is in the backtrace of `gem install --backtrace jekyll` when this error happens.
#
require 'resolv'
host = "rubygems.org"
dns = Resolv::DNS.new
begin
dns.getresource "_rubygems._tcp.#{host}", Resolv::DNS::Resource::IN::SRV
rescue Resolv::ResolvError => e
puts "FREEDOME is off"
rescue SocketError
puts "FREEDOME is on"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment