Skip to content

twilio-ruby 6.0 mangles .rbenv path #655

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
broksonic21 opened this issue May 5, 2023 · 8 comments
Closed

twilio-ruby 6.0 mangles .rbenv path #655

broksonic21 opened this issue May 5, 2023 · 8 comments
Labels
status: waiting for feature feature will be implemented in the future status: waiting for feedback waiting for feedback from the submitter type: bug bug in the library

Comments

@broksonic21
Copy link

Issue Summary

When using 6.0 in an rbenv/bundler setup, this line:

require file.gsub('.rb', '_base.rb') unless file.end_with?('client.rb') || file.end_with?('_base.rb')

mangles paths and thus twilio-ruby can't be used as require "twilio-ruby"

This is because a path like this:

/Users/REDACTED/.rbenv/versions/2.7.8/lib/ruby/gems/2.7.0/gems/twilio-ruby-6.0.0/lib/twilio-ruby/rest/accounts.rb

gets turned into

/Users/REDACTED/.base_rbenv/versions/2.7.8/lib/ruby/gems/2.7.0/gems/twilio-ruby-6.0.0/lib/twilio-ruby/rest/accounts_base.rb

where the .rbenv gets modified into .base_rbenv (when the actual goal was just the filename getting that sub)

Steps to Reproduce

  1. use rbenv
  2. install twilio-ruby
  3. require 'twilio-ruby' ---> it fails

Code Snippet

n/a

Exception/Log

/Users/REDACTED/.rbenv/versions/2.7.8/lib/ruby/gems/2.7.0/gems/twilio-ruby-6.0.0/lib/twilio-ruby/rest/accounts.rb
Traceback (most recent call last):
/Users/REDACTED/.rbenv/versions/2.7.8/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:37:in `require': cannot load such file -- /Users/REDACTED/_base.rbenv/versions/2.7.8/lib/ruby/gems/2.7.0/gems/twilio-ruby-6.0.0/lib/twilio-ruby/rest/accounts_base.rb (LoadError)

Technical details:

  • twilio-ruby version: 6.0.0
  • ruby version: ruby 2.7.8p225 (2023-03-30 revision 1f4d455848) [arm64-darwin22]
  • rbenv version: rbenv 1.2.0
@broksonic21
Copy link
Author

Ah, likely covered by #654

@shrutiburman
Copy link
Contributor

Thanks for the PR. We'll review it soon.Please expect the fix in upcoming release.

@shrutiburman
Copy link
Contributor

Merged with 654.

@shrutiburman shrutiburman added status: ready for deploy code ready to be released in next deploy type: bug bug in the library labels May 8, 2023
@ismasan
Copy link

ismasan commented May 9, 2023

I hit this issue today. I know the fix is already merged, but: wouldn't it have been more reliable to just

base_file = file.gsub(/\.rb$/, '_base.rb')
require base_file if File.exists?(base_file)

... In that wat you let the existence/absence of the base files drive the load behaviour, instead of having to duplicate the logic here and bake in the exception for client.rb

@Azzawie
Copy link

Azzawie commented May 15, 2023

I faced this issue today,

/Users/xxx/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require': cannot load such file -- /Users/xxx/_base.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/twilio-ruby-6.0.0/lib/twilio-ruby/rest/accounts_base.rb (LoadError)

  • gem 'twilio-ruby', '~> 6.0.0'
  • Ruby version 3.1.2
  • gem 'rails', '~> 7.0.4', '>= 7.0.4.3'
  • Bundler version 2.3.24
  • Rbenv version = rbenv 1.2.0

@CanadianTux
Copy link

CanadianTux commented May 16, 2023

I faced the exact same issue as @Azzawie did,

<internal:/Users/[REDACTED]/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:148:in `require': cannot load such file -- /Users/[REDACTED]/_base.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/twilio-ruby-6.0.0/lib/twilio-ruby/rest/accounts_base.rb (LoadError)
    from <internal:/Users/[REDACTED]/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:148:in `require'
    from /Users/[REDACTED]/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/twilio-ruby-6.0.0/lib/twilio-ruby/rest.rb:8:in `block in <top (required)>'
    from /Users/[REDACTED]/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/twilio-ruby-6.0.0/lib/twilio-ruby/rest.rb:7:in `each'
    from /Users/[REDACTED]/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/twilio-ruby-6.0.0/lib/twilio-ruby/rest.rb:7:in `<top (required)>'
    from <internal:/Users/[REDACTED]/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:148:in `require'
    from <internal:/Users/[REDACTED]/.rbenv/versions/3.1.2/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:148:in `require'
    from send_sms.rb:6:in `<main>'

@shrutiburman
Copy link
Contributor

The fix is merged, we're going to release it in the upcoming release this week. Meanwhile please use v5.77.0, if you're blocked by this.

@shrutiburman
Copy link
Contributor

Hi everyone, we've released a new ruby version v6.0.1 with the fix. Please upgrade and let us know if you need further help. Thanks.

Closing this thread, please feel free to open another issue, if this persists.

@shrutiburman shrutiburman added status: waiting for feedback waiting for feedback from the submitter status: waiting for feature feature will be implemented in the future and removed status: ready for deploy code ready to be released in next deploy labels May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for feature feature will be implemented in the future status: waiting for feedback waiting for feedback from the submitter type: bug bug in the library
Projects
None yet
Development

No branches or pull requests

5 participants