braintree_ruby icon indicating copy to clipboard operation
braintree_ruby copied to clipboard

Braintree library errors on Ruby 3.4 due to missing dependencies

Open zorab47 opened this issue 1 year ago • 1 comments

General information

  • SDK/Library version: 4.25
  • Environment: Sandbox and Production
  • Language, language version, and OS: Ruby 3.4.x

Issue description

Related: #247

Loading the braintree Ruby gem errors when loading on Ruby 3.4 due to missing dependencies:

  • base64
  • bigdecimal
❯ ruby -v
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [x86_64-darwin23]

❯ ruby braintree_ruby_dependency_errors.rb
/Users/$HOME/.gem/ruby/3.4.1/gems/braintree-4.25.0/lib/braintree.rb:1: warning: base64 was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0.
You can add base64 to your Gemfile or gemspec to silence this warning.
/Users/$HOME/.rubies/ruby-3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require': cannot load such file -- base64 (LoadError)
        from /Users/$HOME/.rubies/ruby-3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require'
        from /Users/$HOME/.gem/ruby/3.4.1/gems/braintree-4.25.0/lib/braintree.rb:1:in '<top (required)>'
        from /Users/$HOME/.rubies/ruby-3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require'
        from /Users/$HOME/.rubies/ruby-3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require'
        from braintree_ruby_dependency_errors.rb:8:in '<main>'

You can reproduce by running the following with Ruby 3.4:

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'braintree', require: false
end

require "braintree"

zorab47 avatar Jan 31 '25 17:01 zorab47

In addition to the errors above, ruby 3.4.4 also shows warnings for two gems that will be removed in Ruby 3.5. It should be a straightforward fix to just add these to the gem spec in addition to the gems mentioned above.

braintree-4.28.0/lib/braintree.rb:7: warning: logger was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.
You can add logger to your Gemfile or gemspec to silence this warning.
braintree-4.28.0/lib/braintree/webhook_notification.rb:1: warning: ostruct was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.
You can add ostruct to your Gemfile or gemspec to silence this warning.

Fjan avatar Jun 10 '25 12:06 Fjan