Skip to content

Upgrading from 5.40.1 to 5.66.2 raises a LoadError: cannot load such file -- rack/media_type error #605

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

Closed
jasonnoble opened this issue Apr 21, 2022 · 1 comment · Fixed by #606
Labels
type: bug bug in the library

Comments

@jasonnoble
Copy link
Contributor

Issue Summary

I'm upgrading twilio-ruby from 5.40.1 to 5.66.2 and getting the following error:

LoadError:
  cannot load such file -- rack/media_type
# /Users/jasonnoble/.rvm/gems/[email protected]/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:274:in `require'
# /Users/jasonnoble/.rvm/gems/[email protected]/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:274:in `block in require'
# /Users/jasonnoble/.rvm/gems/[email protected]/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:240:in `load_dependency'
# /Users/jasonnoble/.rvm/gems/[email protected]/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:274:in `require'
# /Users/jasonnoble/.rvm/gems/[email protected]/gems/twilio-ruby-5.66.2/lib/rack/twilio_webhook_authentication.rb:3:in `<top (required)>'
# /Users/jasonnoble/.rvm/gems/[email protected]/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:274:in `require'
# /Users/jasonnoble/.rvm/gems/[email protected]/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:274:in `block in require'
# /Users/jasonnoble/.rvm/gems/[email protected]/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:240:in `load_dependency'
# /Users/jasonnoble/.rvm/gems/[email protected]/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:274:in `require'
# /Users/jasonnoble/.rvm/gems/[email protected]/gems/twilio-ruby-5.66.2/lib/twilio-ruby.rb:13:in `<top (required)>'
# /Users/jasonnoble/.rvm/gems/[email protected]/gems/bundler-1.17.3/lib/bundler.rb:114:in `require'
# ./config/application.rb:13:in `<top (required)>'

It appears that this was fixed in #602 via require 'rack/twilio_webhook_authentication' if defined?(Rack). However, the rack/media_type is only available in rack v2 and later (I'm on rack-1.6.13).

Proposed fix:

# lib/twilio-ruby.rb:13
require 'rack/twilio_webhook_authentication' if defined?(Rack) && (Gem.loaded_specs["rack"].version > Gem::Version.new("2"))

A summary of the issue and the environment in which it occurs. If suitable, include the steps required to reproduce the bug. Please feel free to include screenshots, screencasts, or code examples.

Steps to Reproduce

# Gemfile
source 'https://rubygems.org'

ruby '2.7.5'

gem 'rack', '< 2'
gem 'twilio-ruby'

After running bundle install, open an irb session:

2.7.5 :001 > require 'rack'
 => true
2.7.5 :002 > require 'twilio-ruby'
Traceback (most recent call last):
       13: from /Users/jasonnoble/.rvm/rubies/ruby-2.7.5/bin/irb:23:in `<main>'
       12: from /Users/jasonnoble/.rvm/rubies/ruby-2.7.5/bin/irb:23:in `load'
       11: from /Users/jasonnoble/.rvm/rubies/ruby-2.7.5/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
       10: from (irb):2
        9: from /Users/jasonnoble/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:147:in `require'
        8: from /Users/jasonnoble/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:158:in `rescue in require'
        7: from /Users/jasonnoble/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:158:in `require'
        6: from /Users/jasonnoble/.rvm/gems/ruby-2.7.5@twilio/gems/twilio-ruby-5.66.2/lib/twilio-ruby.rb:13:in `<top (required)>'
        5: from /Users/jasonnoble/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:94:in `require'
        4: from /Users/jasonnoble/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:94:in `require'
        3: from /Users/jasonnoble/.rvm/gems/ruby-2.7.5@twilio/gems/twilio-ruby-5.66.2/lib/rack/twilio_webhook_authentication.rb:3:in `<top (required)>'
        2: from /Users/jasonnoble/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:146:in `require'
        1: from /Users/jasonnoble/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:146:in `require'
LoadError (cannot load such file -- rack/media_type)
2.7.5 :003 >

Technical details:

  • twilio-ruby version: 5.66.2
  • ruby version: 2.7.5, 2.6.6
@childish-sambino
Copy link
Contributor

Taking a look at the PR.

@childish-sambino childish-sambino added type: bug bug in the library status: work in progress Twilio or the community is in the process of implementing labels Apr 22, 2022
@childish-sambino childish-sambino removed the status: work in progress Twilio or the community is in the process of implementing label Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug bug in the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants