cane icon indicating copy to clipboard operation
cane copied to clipboard

Ruby 3 incompatibility (call to `File.exists?`)

Open hakanai opened this issue 3 years ago • 1 comments

cane checks currently fail on Ruby 3 because of this call to File.exists?:

https://github.com/square/cane/blob/c8d6ce4e0092e5f677d3a2f409db7566e5d82136/lib/cane/file.rb#L21-L23

This now gives a NoMethodError and suggests File.exist?.

Typical Ruby to delete the method with the correct grammar, if you ask me. :(

hakanai avatar Feb 06 '23 22:02 hakanai

here is what worked for me, I created bin/run_cane:

#!/usr/bin/env ruby

# Monkey patch for File.exists? to alias it to File.exist?
# https://github.com/square/cane/issues/102
if RUBY_VERSION >= '3.2.0' && !File.respond_to?(:exists?)
  class File
    class << self
      alias_method :exists?, :exist?
    end
  end
end

load Gem.bin_path('cane', 'cane')

Monkey patched that one.

c0mrade avatar Dec 13 '24 17:12 c0mrade