steve8x8 / geotoad

Geocaching query tool written in Ruby
https://buymeacoffee.com/steve8x8
Other
28 stars 8 forks source link

Add support for Ruby 3.2 and newer #372

Closed JP95Git closed 5 months ago

JP95Git commented 5 months ago

Running GeoToad (latest version from master) with Ruby 3.2 does not work:

(===) GeoToad 3.34.1 (Ruby 3.2.4p170/2024-04-23 on x64-mingw-ucrt)
( - ) See   https://github.com/steve8x8/geotoad.git   for latest changes and bug reports!
 ***  HTTPS will not verify peer identity!
( - ) Using TLSv1_2 and no SSL verification.
** Press Enter to start the Text User Interface or "X" to exit:
path/to/geotoad/interface/input.rb:52:in `loadConfig': undefined method `exists?' for File:Class (NoMethodError)

    if File.exists?(@configFile)
           ^^^^^^^^
Did you mean?  exist?
        from path/to/geotoad/interface/input.rb:245:in `interactive'
        from geotoad/geotoad.rb:99:in `getoptions'
        from geotoad/geotoad.rb:1127:in `<main>'

The latest working version is Ruby 3.1.5-1.

steve8x8 commented 5 months ago

Congratulations, you hit a bug that's been there for at least 6 or 7 years... but wasn't a bug before.

GeoToad contains a lot of old code, and File.exists? had been coexisting with File.exist? since at least version 1.9.3, with 2.2.0 (?) first declaring File.exists? as deprecated, and maybe 3.2.2 actually removing it - I've seen a report that 3.2.1 still worked ;) Since 1.9.3, despite old and no longer supported, already handles File.exist? I can't see a reason not to get this fixed, there are four files which will need to be modified. (IIRC 1.9.x is a lower version limit anyway .)

I'll make the change to the repo, but will have to decide whether I'll go through a full release process. In the meantime, you may run grep -rl 'File.exists' * | xargs -rt -n1 sed -i.BAK -e 's~File.exists~File.exist~g' in your checkout tree :)

Thanks for the report, I'm afraid there may be more such stuff lurking :/

JP95Git commented 5 months ago

Thanks for the quick fix!

No need to release a new version as I use the version from the master branch. It even works with with Ruby 3.3: (===) GeoToad 3.34.1 (Ruby 3.3.1p55/2024-04-23 on x64-mingw-ucrt)