If you are using File.dirname to get the directory path and delete and do some other processing on path, then make sure you consider below...
ruby-3.1.2