Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby 3 incompatibility (call to File.exists?) #102

Open
hakanai opened this issue Feb 6, 2023 · 1 comment
Open

Ruby 3 incompatibility (call to File.exists?) #102

hakanai opened this issue Feb 6, 2023 · 1 comment

Comments

@hakanai
Copy link

hakanai commented Feb 6, 2023

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

cane/lib/cane/file.rb

Lines 21 to 23 in c8d6ce4

def exists?(path)
::File.exists?(path)
end

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

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

@c0mrade
Copy link

c0mrade commented Dec 13, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants