iex(1)> File.mkdir!("tmp")
:ok
iex(2)> File.write!("tmp/file", <<1>>)
:ok
iex(3)> File.rmdir!("tmp")
** (File.Error) could not remove directory "tmp": file already exists
(elixir) lib/file.ex:816: File.rmdir!/1
iex(1)> File.mkdir!("tmp")
:ok
iex(2)> File.write!("tmp/file", <<1>>)
:ok
iex(3)> File.rmdir!("tmp")
** (File.Error) could not remove directory "tmp": directory contains file(s)
(elixir) lib/file.ex:816: File.rmdir!/1
Unfortunately we are relaying the posix error message which is eexist: http://lxr.free-electrons.com/source/include/uapi/asm-generic/errno-base.h#L20
We could change it specially for rmdir! but I would prefer to note in the documentation rather than change the underlying unix error semantics.
I think we should tailor this particular message.
Current message is extremely disguising because it's telling you it cannot remove a dir, because this dir exists! WTH??!
It is not intuitive for users to go and read the documentation for rmdir when they see a message like this.
this is what GNU coreutils does
$ mkdir foo && touch foo/bar && rmdir foo
rmdir: failed to remove 'foo': Directory not empty
@eksperimental Given that rmdir example, I am convinced. Thank you. :heart:
I can take care of it if @Fahrradflucht is alright with it.
@eksperimental sure go ahead
Most helpful comment
@eksperimental Given that rmdir example, I am convinced. Thank you. :heart: