Skip to content

CLI: error on a non-existent oldfile/newfile#921

Merged
lrytz merged 1 commit into
scala-garden:mainfrom
kubukoz:error-on-missing-bin-path
Jun 17, 2026
Merged

CLI: error on a non-existent oldfile/newfile#921
lrytz merged 1 commit into
scala-garden:mainfrom
kubukoz:error-on-missing-bin-path

Conversation

@kubukoz

@kubukoz kubukoz commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Problem

Passing a path that doesn't exist as the CLI's oldfile/newfile was silently absorbed by MiMaLib's empty-package fallback:

  • non-existent oldfile → no output, exit 0 (silently looks "compatible" — the file is effectively dropped)
  • non-existent newfile → a flood of false MissingClass problems
# silent, exit 0 — bug
mima /does/not/exist.jar some-real.jar

# flood of MissingClass — bug
mima some-real.jar /does/not/exist.jar

Fix

Validate in the CLI that oldfile and newfile exist, throwing IllegalArgumentException otherwise. main already 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 in MiMaLib.createPackage is intentional and load-bearing: 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 #768). A first attempt that added the existence check in MiMaLib broke exactly that case in CI — so the check belongs where a user-typed path is genuinely expected to exist.

Verification

  • mima <missing> <real> and mima <real> <missing> → clear error + usage
  • mima <real> / (existing but class-less path) → unchanged behavior, no error
  • coreJVM/test green; sbtplugin/scripted sbt-mima-plugin/pom-only-project passes

🤖 Generated with Claude Code

@kubukoz kubukoz force-pushed the error-on-missing-bin-path branch from 8bf5820 to b18ab6c Compare June 16, 2026 17:55
@kubukoz kubukoz changed the title Error on a non-existent old/new file CLI: error on a non-existent oldfile/newfile Jun 16, 2026
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>
@kubukoz kubukoz force-pushed the error-on-missing-bin-path branch from b18ab6c to 7800d62 Compare June 16, 2026 17:58
@kubukoz kubukoz marked this pull request as ready for review June 16, 2026 18:08
@lrytz lrytz merged commit 9c16d29 into scala-garden:main Jun 17, 2026
10 checks passed
@kubukoz kubukoz deleted the error-on-missing-bin-path branch June 17, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants