CLI: error on a non-existent oldfile/newfile#921
Merged
Conversation
8bf5820 to
b18ab6c
Compare
Passing a path that does not exist as the CLI's oldfile or newfile was silently absorbed by MiMaLib's empty-package fallback: - non-existent oldfile -> no output, exit 0 (silently "compatible") - non-existent newfile -> a flood of false MissingClass problems The empty-package fallback itself is intentional and must stay: the sbt plugin relies on it for POM-only modules, whose target/scala-*/classes directory legitimately does not exist (see the pom-only-project scripted test and issue scala-garden#768). So the existence check belongs in the CLI, where a path the user typed really is expected to exist, not in MiMaLib. main already catches IllegalArgumentException and prints usage, so both bad inputs now produce a clear error. Adds MainSpec covering both error cases plus the existing-but-class-less path (which must still succeed). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
b18ab6c to
7800d62
Compare
lrytz
approved these changes
Jun 17, 2026
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.
Problem
Passing a path that doesn't exist as the CLI's
oldfile/newfilewas silently absorbed byMiMaLib's empty-package fallback:MissingClassproblemsFix
Validate in the CLI that
oldfileandnewfileexist, throwingIllegalArgumentExceptionotherwise.mainalready catches that and prints usage, so both bad inputs now produce a clear error.The check deliberately lives in the CLI, not in
MiMaLib. The empty-package fallback inMiMaLib.createPackageis intentional and load-bearing: the sbt plugin relies on it for POM-only modules, whosetarget/scala-*/classesdirectory legitimately does not exist (see thepom-only-projectscripted test and #768). A first attempt that added the existence check inMiMaLibbroke exactly that case in CI — so the check belongs where a user-typed path is genuinely expected to exist.Verification
mima <missing> <real>andmima <real> <missing>→ clear error + usagemima <real> /(existing but class-less path) → unchanged behavior, no errorcoreJVM/testgreen;sbtplugin/scripted sbt-mima-plugin/pom-only-projectpasses🤖 Generated with Claude Code