ruby-on-railsruntime-errornokogirilibxml-ruby

Rails/Paperclip/S3 mystery errors: undefined method "global_endpoint?"


So I upgraded a Rails app from 3.0 to 4.0 last week, and ever since I've been getting strange errors that seem to point to random places that I haven't changed, and I can't reproduce them.

One such error is like this:

NoMethodError: undefined method `global_endpoint?' for AWS::S3:Class

[GEM_ROOT]/gems/aws-sdk-1.46.0/lib/aws/core/configuration.rb:441

/gems/aws-sdk-1.46.0/lib/aws/core/configuration.rb:441 in "block in add_service"
/gems/aws-sdk-1.46.0/lib/aws/core/configuration.rb:361 in "call"
/gems/aws-sdk-1.46.0/lib/aws/core/configuration.rb:361 in "block in add_option"
/gems/aws-sdk-1.46.0/lib/aws/core/configuration.rb:381 in "block (2 levels) in add_option_with_needs"
/gems/aws-sdk-1.46.0/lib/aws/core/configuration.rb:381 in "each"
/gems/aws-sdk-1.46.0/lib/aws/core/configuration.rb:381 in "inject"
/gems/aws-sdk-1.46.0/lib/aws/core/configuration.rb:381 in "block in add_option_with_needs"
/gems/aws-sdk-1.46.0/lib/aws/core/service_interface.rb:73 in "initialize"
/gems/paperclip-4.1.1/lib/paperclip/storage/s3.rb:239 in "new"
/gems/paperclip-4.1.1/lib/paperclip/storage/s3.rb:239 in "obtain_s3_instance_for"
/gems/paperclip-4.1.1/lib/paperclip/storage/s3.rb:233 in "s3_interface"
/gems/paperclip-4.1.1/lib/paperclip/storage/s3.rb:243 in "s3_bucket"
/gems/paperclip-4.1.1/lib/paperclip/storage/s3.rb:247 in "s3_object"
/app/models/my_model.rb:49 in "block in my_download_url"

This will randomly occur on a page that has a model with a paperclip attachment saved on S3. Reloading the page will sometimes cause it again, but usually it will reload properly without incident.

I don't know what to do to debug it, since I can't even get it to happen at will.

Any help or ideas?


Solution

  • Solved it! Only took a year and a half of searching! Turns out it's related to some bad memory hooks in the libxml-ruby gem. See here:

    https://github.com/sparklemotion/nokogiri/issues/881 https://github.com/sparklemotion/nokogiri/issues/1364

    Removing libxml-ruby from my Gemfile fixed it.