Skip to content

Create the directories of generated files - #832

Merged
pepone merged 2 commits into
icerpc:mainfrom
pepone:issue-831
Oct 16, 2026
Merged

pepone merged 2 commits into
icerpc:mainfrom
pepone:issue-831

Conversation

@pepone

@pepone pepone commented Oct 16, 2026

Copy link
Copy Markdown
Member

write_generated_file opened the output path with File::create, which fails when the path's directory does not
exist. slicec reported E001: unable to write generated file ... No such file or directory for a generated file with
a nested path, such as com/example/Point.java, and for any generated file when --output-dir names a directory that
does not exist yet. This change creates the parent directory with create_dir_all before creating the file.

Fixes #831

What's Changed

slicec:

  • Generated files are written even when their directory does not exist yet: slicec creates the --output-dir
    directory and the subdirectories of the paths that code generators return.

write_generated_file opened the output path with File::create, which fails with "No such file or directory" when
the path's directory does not exist: for a generated file with a nested path, such as com/example/Point.java, or for
any file when --output-dir names a directory that does not exist yet. Create the parent directory first.
Copilot AI balanced review requested due to automatic review settings October 16, 2026 11:25
@pepone pepone added the slicec Related to the 'slicec' crate label Oct 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@InsertCreativityHere InsertCreativityHere left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!
Just one suggestion on the comment, of course :)

Comment thread slicec/src/main.rs Outdated
Co-authored-by: Austin Henriksen <austin.r.henriksen79@gmail.com>
@pepone
pepone merged commit cbf8eec into icerpc:main Oct 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

slicec Related to the 'slicec' crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

slicec cannot write generated files into directories that don't exist

3 participants