janfri / mini_exiftool

This library is a wrapper for the Exiftool command-line application (https://exiftool.org) written by Phil Harvey. It provides the full power of Exiftool to Ruby: reading and writing of EXIF-data, IPTC-data and XMP-data. Branch master is for actual development and branch compatibility-version is for compatibility with Ruby 1.8 and exiftool versions prior 7.65.
GNU Lesser General Public License v2.1
213 stars 52 forks source link

"require 'rational' " causes load error(cannot load such file -- rational) for ruby 2.7.8 #47

Closed tomwang57 closed 5 months ago

tomwang57 commented 5 months ago

ruby version: 2.7.8 bundler version: 2.3.3

.rbenv/versions/2.7.8/lib/ruby/gems/2.7.0/gems/mini_exiftool-2.10.2/lib/mini_exiftool.rb:20:in `require': cannot load such file -- rational (LoadError)

It seems that require 'rational' is no longer needed to use Rational.

janfri commented 5 months ago

On my system with Ruby 3.0.6 it causes no error:

>> RUBY_VERSION
=> "3.0.6"
>> require 'rational'
=> false
>> 
janfri commented 5 months ago

Does the following work in irb for you?

Rational(1, 2)
tomwang57 commented 5 months ago

Does the following work in irb for you?

Rational(1, 2)

Yes, this works

tomwang57 commented 5 months ago

On my system with Ruby 3.0.6 it causes no error:

>> RUBY_VERSION
=> "3.0.6"
>> require 'rational'
=> false
>> 

It is used in a Rails project with Gemfile like:

...
gem 'mini_exiftool_vendored'
...

And running bundle install caused the error. But i can't reproduce this error with a branch new project. I will provide more detail if possible.

tomwang57 commented 5 months ago

Add the following line before Bundler.require(*Rails.groups) fixes the error:

# fix: cannot load such file -- rational
require 'mini_exiftool_vendored'

Don't know why.