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

Replace deprecated File#exists? with File#exist? for ruby >= 3.2 #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Vinnehboom
Copy link

For any projects built with a ruby version of 3.2.0 or higher, the cap setup command will fail with the following error:

... 
      01 CREATE DATABASE
    ✔ 01 ubuntu@15.188.115.192 0.604s
00:01 postgresql:generate_database_yml_archetype
      01 mkdir -pv /home/ubuntu/projects/office_hardware_management/staging/db
      01 mkdir: created directory '/home/ubuntu/projects/office_hardware_management/staging/db'
    ✔ 01 ubuntu@15.188.115.192 0.101s
#<Thread:0x000000010968f7e0 /Users/vinnie-bp/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/sshkit-1.21.4/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
/Users/vinnie-bp/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/sshkit-1.21.4/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as ubuntu@15.188.115.192: undefined method `exists?' for File:Class (SSHKit::Runner::ExecuteError)
        from /Users/vinnie-bp/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/sshkit-1.21.4/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/Users/vinnie-bp/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/capistrano-postgresql-6.2.0/lib/capistrano/postgresql/helper_methods.rb:50:in `pg_template': undefined method `exists?' for File:Class (NoMethodError)

          if File.exists?(config_file) # If there is a customized file in your rails app template directory, use it and convert any ERB
                 ^^^^^^^^
Did you mean?  exist?
        from /Users/vinnie-bp/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/capistrano-postgresql-6.2.0/lib/capistrano/tasks/postgresql.rake:127:in `block (3 levels) in <top (required)>'
        from /Users/vinnie-bp/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/sshkit-1.21.4/lib/sshkit/backends/abstract.rb:31:in `instance_exec'
        from /Users/vinnie-bp/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/sshkit-1.21.4/lib/sshkit/backends/abstract.rb:31:in `run'
        from /Users/vinnie-bp/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/sshkit-1.21.4/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as ubuntu@15.188.115.192: undefined method `exists?' for File:Class


Caused by:
NoMethodError: undefined method `exists?' for File:Class

Tasks: TOP => postgresql:generate_database_yml_archetype

The ruby changelogs refer to the deprecation of the #exists? method.

We can use the alias #exist? (ref)

@tomprats
Copy link

Works for me! Sorry, was thinking I had write access for a second

@NorseGaud
Copy link
Member

@tomprats , I can't help maintain this anymore due to other engagements. I've sent you an invite to have write access.

@tomprats
Copy link

Thank you for your previous work on this, really appreciate it!

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

Successfully merging this pull request may close these issues.

3 participants