Skip to content

File.exists? removed in Ruby 3.2 #97

@SeanLF

Description

@SeanLF

After upgrading to Ruby 3.2, we had the following error pop up in Sentry:

NoMethodError: undefined method `exists?' for File:Class (NoMethodError)

          File.delete(ssl_filename) if File.exists?(ssl_filename)
                                           ^^^^^^^^
Did you mean?  exist?
  from rubycas-client (2.3.9) lib/casclient/tickets/storage.rb:129:in `cleanup_service_session_lookup'

According to Ruby 3.2's changelogs, File.exists has been removed:

Removed methods
The following deprecated methods are removed.

[...]
File.exists? [Feature #17391]


There are two references to File.exists? in the codebase, which need to be updated to File.exist?

return IO.read(ssl_filename) if File.exists?(ssl_filename)
end
# Removes a stored relationship between a ServiceTicket and a local
# Rails session id. This should be called when the session is being
# closed.
#
# See #store_service_session_lookup.
def cleanup_service_session_lookup(st)
raise CASException, "No service_ticket specified." if st.nil?
st = st.ticket if st.kind_of? ServiceTicket
ssl_filename = filename_of_service_session_lookup(st)
File.delete(ssl_filename) if File.exists?(ssl_filename)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions