em/version.rb:2: warning: already initialized constant VERSION #284

Merged
merged 1 commit into from Feb 28, 2013

Conversation

Projects
None yet
3 participants
Contributor

ngauthier commented Dec 13, 2011

When I am using ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux] and I am using bundler to require eventmachine, I get this error:

gems/ruby/1.8/bundler/gems/eventmachine-3c8ea2ed3d81/lib/em/version.rb:2: warning: already initialized constant VERSION

I traced out the places where em/version.rb is required and it was in two places: bundler loading the gemspec, and then bundler requiring the gem.

The issue is that the gemspec loads the version like this:

require File.expand_path('../lib/em/version', __FILE__)

Which evaluates to the full system path to the version file. But bundler requires em/version. Ruby 1.8.7 does not realized it has already been required and so it loads the file again.

It is my understanding that ruby 1.9.2's require is smarter, but in 1.8.7 this outputs a constant warning.

I borrowed this solution from the Asquera/vagrant project: Asquera/vagrant@b26d588

The gem builds and tests pass except the sockopt test which is failing because I don't have permission to set sockopts on my system and I'm too dumb to figure that out right now.

xoxo @ngauthier

olistik commented Jan 24, 2012

What about using version sniffing?

if RUBY_VERSION == '1.8.7'
  $:.unshift File.expand_path("../lib", __FILE__)
  require "em/version"
else
  # ruby 1.9
  require File.expand_path('../lib/em/version', __FILE__)
end

tmm1 merged commit 933b388 into eventmachine:master Feb 28, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment