Remove yecc/leex generated .erl files on deps.clean, closes #8262#15318
Open
Ch4s3 wants to merge 1 commit intoelixir-lang:mainfrom
Open
Remove yecc/leex generated .erl files on deps.clean, closes #8262#15318Ch4s3 wants to merge 1 commit intoelixir-lang:mainfrom
Ch4s3 wants to merge 1 commit intoelixir-lang:mainfrom
Conversation
b806483 to
eccb15d
Compare
…ng#8262 mix deps.clean and mix clean --deps now delete .erl files that were generated by yecc/leex compilers into a dep's source tree. For Mix- compiled deps, generated paths are read from .mix/compile.{yecc,leex} manifests before the build directory is removed. For rebar3 deps (which never write Mix manifests), generated files are inferred by scanning the dep source tree for .yrl/.xrl files and deleting the co-located .erl with the same basename. mix clean --deps now also acquires the deps lock when modifying dep source files. Assisted-by: Claude:claude-sonnet-4-6 Signed-off-by: Chase Gilliam <chase.gilliam@gmail.com>
eccb15d to
5555028
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8262.
mix deps.cleanandmix clean --depsremove _build artifacts but never clean the.erlfiles that yecc/leex write back into deps//src/. Unlike every other compiler, yecc and leex use the same directory for input and output, so generated files accumulate across clean/compile cycles and survivedeps.clean --all.Solution
Mix-compiled deps: Before deleting
_build, read.mix/compile.{yecc,leex}manifests (which store output paths relative to the dep's source root), expand each path against dep.opts[:dest], and delete it. Astarts_with?(expanded, dest <> "/")guard prevents path traversal.Rebar3 deps: Rebar3 never writes Mix manifests. When no manifests are found, fall back to scanning the dep source tree for
.yrl/.xrlfiles and deleting the co-located.erlwith the same basename. Hand-written.erlfiles with no grammar counterpart are never touched.Lock ordering:
mix clean --depsnow wraps the source-file cleanup inwith_deps_lock(nested inside the existing with_build_lock), matching whatmix deps.cleanalready does and closing a race with concurrentmix deps.get.Files changed"
deps.clean.ex— adds clean_generated_sources/4, wired in before clean_build; File.rm failures now reported via maybe_warn_failed_file_deletionclean.ex— calls clean_generated_sources under with_deps_lock in the --deps branchtest/fixtures/clean_with_yecc/— new fixture with a Mix dep (yecc + leex + hand-written .erl), and a rebar3 depdeps.clean_test.exs— 13 new tests: both compilers, hand-written preservation, non-standard erlc_paths, --build/--all, multi-env deduplication, --only scoping, rebar3 scan fallback, idempotency, path traversalclean_test.exs— 2 new tests: --deps removes generated files; --deps --only dev scopes to dev environment only