Skip to content

Conversation

@sferik
Copy link
Contributor

@sferik sferik commented Jul 17, 2025

Ensure FileUtils.remove_dir is passed a directory. Add a unit test verifying that Errno::ENOTDIR is raised when calling remove_dir on a non-directory/file.

This may cause some existing "working" programs to error, but in a way that prevents users from accidentally deleting files, which seems like a safer approach than allowing the program to delete the file and continue running.

Removes FIXME added in 2005 by @aamine.

@nobu
Copy link
Member

nobu commented Jul 19, 2025

I'm unsure this can cause severe compatibility issues.
Let's give a try.

@nobu nobu merged commit 9618ce5 into ruby:master Jul 19, 2025
ivoanjo added a commit to DataDog/libdatadog that referenced this pull request Jul 25, 2025
Some of our tests use

```ruby
let(:temporary_directory) { "does/not/exist" }
```

and in ruby/fileutils#132 the behavior of
`FileUtils.remove_dir` was tweaked to change the exception that gets
raised when doing `FileUtils.remove_dir` with a directory that doesn't
exist.

I've updated the test clean-up hook with the new exception as well.
dd-mergequeue bot pushed a commit to DataDog/libdatadog that referenced this pull request Jul 25, 2025
* Fix specs failing due to slightly changed behavior on ruby-master

Some of our tests use

```ruby
let(:temporary_directory) { "does/not/exist" }
```

and in ruby/fileutils#132 the behavior of
`FileUtils.remove_dir` was tweaked to change the exception that gets
raised when doing `FileUtils.remove_dir` with a directory that doesn't
exist.

I've updated the test clean-up hook with the new exception as well.

* Minor: Add `irb` to development dependencies

May come in handy sometimes (and does not affect what we ship to
customers).

* Minor: Refresh rspec configuration

As per https://ivoanjo.me/blog/2016/09/25/why-you-should-regenerate-your-spec-helper/
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.

2 participants