Skip to content

Conversation

@fliiiix
Copy link
Contributor

@fliiiix fliiiix commented Nov 7, 2025

Improve the error message when the output directory is not writable.

After:

error:
  Output path: readonly/ is not writable

Before:

error:
  Unable to generate Rust for monster

This runs only if the cpp version is 17 or higher since writing this check platform independent without std::filesystem would be a huge pain and a lot more code. Pre cpp17 versions will just fall back to the error message from before and assume the directory is always writable.

@github-actions github-actions bot added c++ codegen Involving generating code from schema labels Nov 7, 2025
@fliiiix
Copy link
Contributor Author

fliiiix commented Nov 18, 2025

@aardappel any thoughts on this?

Only if compiled with cpp17
@fliiiix fliiiix force-pushed the feature/better-error-handling-output branch from c82ad9d to bdb7513 Compare November 18, 2025 09:17
@aardappel
Copy link
Collaborator

Hmm, I am not sure how I feel about creating a file and then deleting it just for the purpose of seeing if a directory is writable. It seems messy an possibly inefficient.

And if all we're doing is checking if the file fails to open for writing, can't we derive that same information from the actual files we're trying to write and produce a better error there? Or just Unable to generate Rust for monster (failed to open file for writing) or whatever?

Esp since dirs locked for writing doesn't seem like a frequent occurrence.

@fliiiix
Copy link
Contributor Author

fliiiix commented Nov 24, 2025

It seems messy an possibly inefficient.

I looked into it and it seems that is unfortunately the most reliable way to check for it.

can't we derive that same information from the actual files we're trying to write and produce a better error there?

I guess you are correct that is what we should do. I think i did not go down this path because this requires a bit more refactoring. But since this also came up here that we need a better way to forward errors from the code generators itself i will look into how we could achieve this.
This has the added benefit that this should also work with cpp-11.

Esp since dirs locked for writing doesn't seem like a frequent occurrence.

the usecase we had is that src is mounted read-only into the container, and it took us a long time to figure out why flatc was failing.

@fliiiix fliiiix marked this pull request as draft November 24, 2025 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ codegen Involving generating code from schema

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants