Skip to content

ldc-build-runtime: require absolute --buildDir for --reset#5128

Open
ramen-bully wants to merge 1 commit into
ldc-developers:masterfrom
revate:ldc-build-runtime-refuse-relative-reset
Open

ldc-build-runtime: require absolute --buildDir for --reset#5128
ramen-bully wants to merge 1 commit into
ldc-developers:masterfrom
revate:ldc-build-runtime-refuse-relative-reset

Conversation

@ramen-bully
Copy link
Copy Markdown

disclaimer i used AI.
When --reset / --resetOnly is passed and --buildDir is a relative path (including the default ldc-build-runtime.tmp), the deletion loop resolves the path against the current working directory at the moment the tool runs. If that CWD happens to be a project root — for example ldc-build-runtime --buildDir=. --reset invoked from the project — the loop iterates the project's top-level entries and removes every file plus every subdirectory not literally named ldc-src. This has destroyed working repositories.

Refuse to proceed when --reset is requested with a relative --buildDir, and resolve the path to absolute before any deletion runs. Builds without --reset continue to accept relative paths unchanged (no deletion happens, so no destruction risk).

note - i got burned pretty badly by this...

When --reset / --resetOnly is passed and --buildDir is a relative
path (including the default `ldc-build-runtime.tmp`), the deletion
loop resolves the path against the current working directory at the
moment the tool runs. If that CWD happens to be a project root —
for example `ldc-build-runtime --buildDir=. --reset` invoked from
the project — the loop iterates the project's top-level entries and
removes every file plus every subdirectory not literally named
`ldc-src`. This has destroyed working repositories.

Refuse to proceed when --reset is requested with a relative
--buildDir, and resolve the path to absolute before any deletion
runs. Builds without --reset continue to accept relative paths
unchanged (no deletion happens, so no destruction risk).
@kinke
Copy link
Copy Markdown
Member

kinke commented May 14, 2026

Hmm, I think this is perfectly fine when e.g. not specifying a build dir explicitly, so using the pretty safe relative ldc-build-runtime.tmp default. It might pay off to refuse to do this for dangerous relative paths only, like . and any starting with ...

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