Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.5.1 warnings #84

Open
mfojtik opened this issue May 9, 2011 · 4 comments
Open

2.5.1 warnings #84

mfojtik opened this issue May 9, 2011 · 4 comments

Comments

@mfojtik
Copy link
Contributor

mfojtik commented May 9, 2011

Hi,

i'm getting a couple of warning on Ruby 1.8 (Fedora 14):

/usr/lib/ruby/gems/1.8/gems/aws-2.5.1/lib/ses/../awsbase/utils.rb:105: warning: already initialized constant HEX
/usr/lib/ruby/gems/1.8/gems/aws-2.5.1/lib/ses/../awsbase/utils.rb:107: warning: already initialized constant TO_REMEMBER
/usr/lib/ruby/gems/1.8/gems/aws-2.5.1/lib/ses/../awsbase/utils.rb:108: warning: already initialized constant ASCII
/usr/lib/ruby/gems/1.8/gems/aws-2.5.1/lib/ses/../awsbase/errors.rb:128: warning: already initialized constant DEFAULT_CLOSE_ON_4XX_PROBABILITY
/usr/lib/ruby/gems/1.8/gems/aws-2.5.1/lib/ses/../awsbase/parsers.rb:47: warning: already initialized constant DEFAULT_XML_LIBRARY
/usr/lib/ruby/gems/1.8/gems/aws-2.5.1/lib/ses/../awsbase/awsbase.rb:66: warning: already initialized constant AMAZON_PROBLEMS
/usr/lib/ruby/gems/1.8/gems/aws-2.5.1/lib/ses/../awsbase/awsbase.rb:86: warning: already initialized constant DEFAULT_SIGNATURE_VERSION

-- Michal

@treeder
Copy link
Member

treeder commented May 9, 2011

Looks like it may have to do with this line in ses.rb:

require_relative "../awsbase/awsbase"

Could you verify that?

@dotdotdotpaul
Copy link

I commented that line out and it squelched the warnings for me. Haven't done a significant test of the codebase, though my code accessing S3 appears to have succeeded just fine... Would be nice to get that patched into a gem release.

@ctm
Copy link
Contributor

ctm commented Jul 11, 2011

To get rid of warnings in a 2.3.4 Rails app that uses MRI 1.8.7, I added the following to config/preinitializer.rb:

# This is a different implementation of require_relative than the one
# supplied in the aws-2.5.6 codebase.  Theirs causes duplicate
# requires and the consequent "already initialized constant" warnings.

# see vendor/ruby/1.8/gems/aws-2.5.6/lib/awsbase/require_relative.rb
# and https://github.com/appoxy/aws/issues/84

unless Kernel.respond_to?(:require_relative)
  module Kernel
    def require_relative(path)
      desired_path = File.expand_path('../' + path.to_str, caller[0])
      shortest = desired_path
      $:.each do |path|
        path += '/'
        if desired_path.index(path) == 0
          candidate = desired_path.sub(path, '')
          shortest = candidate if candidate.size < shortest.size
        end
      end
      require shortest
    end
  end
end

It seems to work for me.

@nathancolgate
Copy link

@ctm Thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants