Skip to content

Conversation

@bcpeinhardt
Copy link
Owner

The easy part:
There was a typo in the error conversion code causing Enotdir to come through as Unknown("ENOTDIR") on the JS target. I've simply fixed the typo.

The hard part:
There is an inconsistency with the error messages returned for create_directory_all when the caller doesn't have permissions for the provided path.
It comes down to the behavior of file:make_dir in erlang, which is called by filelib:ensure_path which is called by simplifile. From the function's docs:

enotdir - A component of Dir is not a directory. On some platforms, enoent is returned instead.

I'm quite certain there are more inconsistencies like this in simplifile, where the particular error returned varies by the unique combination of runtime and platform. I wrote a custom ensure_dir impl that made the error consistent, but it relied on an extra sys call in the recursion, which didn't feel like a worthwhile tradeoff.

In general, I would like simplifile's behavior to be "as consistent as possible" across the runtimes on different platforms, so I'll keep looking into solutions here.

fixes #50

@bcpeinhardt bcpeinhardt merged commit 02f8866 into main Nov 6, 2025
1 check passed
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.

Different FileError on create_directory_all between JS and Erlang targets

2 participants