kubo / ruby-oci8

Ruby-oci8 - Oracle interface for ruby
Other
169 stars 78 forks source link

Use `File.exist?` instead of removed `File.exists?` in Ruby 3.2 #242

Closed yahonda closed 2 years ago

yahonda commented 2 years ago

Ruby 3.2 removes deprecated File.exists? method via https://github.com/ruby/ruby/pull/5352

$ ruby -v
ruby 3.2.0dev (2021-12-29T00:37:59Z master d75f7078c8) [x86_64-linux]
$ ruby setup.rb config
---> lib
---> lib/oci8
<--- lib/oci8
---> lib/dbd
<--- lib/dbd
<--- lib
---> ext
---> ext/oci8
/home/yahonda/.rbenv/versions/3.2.0-dev/bin/ruby /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/extconf.rb
attempting to locate oracle-instantclient...
checking load library path...
  LD_LIBRARY_PATH...
    checking /usr/lib/oracle/21/client64/lib... yes
  /usr/lib/oracle/21/client64/lib/libclntsh.so.10.1 looks like an instant client.
checking for cc... ok
checking for gcc... yes
checking for LP64... yes
checking for sys/types.h... yes
checking for ruby header... ok
---------------------------------------------------
Error Message:
  undefined method `exists?' for File:Class

        File.exists?("#{dir}/oci.h")
            ^^^^^^^^
  Did you mean?  exist?
Backtrace:
  /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:1064:in `block in initialize'
  /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:1063:in `each'
  /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:1063:in `find'
  /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:1063:in `initialize'
  /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:271:in `new'
  /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:271:in `get'
  /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/extconf.rb:22:in `<main>'
---------------------------------------------------
See:
 * http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-full-client.md for Oracle full client
 * http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-instant-client.md for Oracle instant client
 * http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/install-on-osx.md for OS X
 * http://www.rubydoc.info/github/kubo/ruby-oci8/file/docs/report-installation-issue.md to report an issue.

/home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:1064:in `block in initialize': RuntimeError (RuntimeError)
    from /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:1063:in `each'
    from /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:1063:in `find'
    from /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:1063:in `initialize'
    from /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:271:in `new'
    from /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:271:in `get'
    from /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/extconf.rb:22:in `<main>'
/home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:1064:in `block in initialize': undefined method `exists?' for File:Class (NoMethodError)

      File.exists?("#{dir}/oci.h")
          ^^^^^^^^
Did you mean?  exist?
    from /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:1063:in `each'
    from /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:1063:in `find'
    from /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:1063:in `initialize'
    from /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:271:in `new'
    from /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/oraconf.rb:271:in `get'
    from /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/extconf.rb:22:in `<main>'
'system /home/yahonda/.rbenv/versions/3.2.0-dev/bin/ruby /home/yahonda/src/github.com/kubo/ruby-oci8/ext/oci8/extconf.rb ' failed
Try 'ruby setup.rb --help' for detailed usage.
$

Offenses:

ext/oci8/oraconf.rb:538:43: W: [Corrected] Lint/DeprecatedClassMethods: File.exists? is deprecated in favor of File.exist?. raise <<EOS unless File.exists?(libname) ^^^^^^^ ext/oci8/oraconf.rb:1064:12: W: [Corrected] Lint/DeprecatedClassMethods: File.exists? is deprecated in favor of File.exist?. File.exists?("#{dir}/oci.h") ^^^^^^^ ruby-oci8.gemspec:53:36: W: [Corrected] Lint/DeprecatedClassMethods: File.exists? is deprecated in favor of File.exist?. so_files << map_file if File.exists? map_file ^^^^^^^

53 files inspected, 3 offenses detected, 3 offenses corrected $