Repository navigation
Fix Maven local repository lookup (#423) - #1801
Conversation
Assisted-by: Claude Code:claude-opus-5-5
Agent mode and -g looked for the Maven local repository in
$M2_HOME/repository, which is the Maven install, and never read
<localRepository> from settings.xml. On Windows they also preferred
HOME over the profile directory Java uses. With any of these, scan -g
found 0 packages, and rollback -g dropped the patch record while the
real local repository stayed patched.
The lookup now follows Maven: MAVEN_REPO_LOCAL, then
-Dmaven.repo.local in MAVEN_ARGS or MAVEN_OPTS, then <localRepository>
in the user settings, then in the install's conf/settings.xml, then
.m2/repository under user.home. user.home honours -Duser.home and is
USERPROFILE on Windows. ${user.home} and ${env.X} expand in settings.
Fixes #423
Assisted-by: Claude Code:claude-opus-5-5
The integration test asserted the old $M2_HOME/repository lookup. It now checks that $M2_HOME/repository is not scanned and that the install's conf/settings.xml <localRepository> is. Assisted-by: Claude Code:claude-opus-5-5
Maven reads a CDATA <localRepository> as its text and decodes entities, ignores a profile property of the same name, and fixes user.home before command-line -D flags in MAVEN_ARGS apply. The lookup now does the same. CLI e2e children also drop MAVEN_OPTS, MAVEN_ARGS, MAVEN_HOME and M2_HOME so a developer's Maven setup can't redirect their crawl. Assisted-by: Claude Code:claude-opus-5-5
A FIFO planted where settings.xml is expected is now refused instead of blocking the crawl in open(2), as the crawler architecture test requires for every crawler read. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
A comment inside <localRepository> in settings.xml was kept as part of the path, so the crawler fell back to ~/.m2/repository while Maven used the real local repository. The value is now read as Maven's parser reads it: comments drop out, entities decode, CDATA is kept verbatim. The Maven crawler e2e tests also clear M2_HOME now, so a host Maven install's settings.xml can't steer tests that pin the repo list. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
|
Labeled Ready for review by the burn-down agent.
Generated by Claude Code |
m2_repo_path_treats_empty_m2_home_as_unset now reads the user's settings.xml, so a developer whose ~/.m2/settings.xml sets <localRepository> got a red cargo test. Point HOME/USERPROFILE at an empty temp dir for that test. Also drop a format! with no placeholders in local_repo_tests, which clippy --all-targets flags as useless_format. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
bugbot run Final reviewer: pushed 72f4c71 (test-only). It makes Generated by Claude Code |
|
Labeled Ready for review again by the burn-down agent, after the final reviewer's test-only push.
Generated by Claude Code |
|
Burn-down agent: Ready for review again at
Slack announcement not sent this run (the Slack send tool was not available to the agent); the next run retries. Generated by Claude Code |
|
Final review of 72f4c71 found one blocker and fixed it in a39bc39:
Non-blocking notes, each a possible follow-up rather than a change for this PR:
Generated by Claude Code |
Three local_repo_tests put a tempdir path into MAVEN_OPTS/MAVEN_ARGS but resolved with Os::Unix. Unix-mode split_opts treats backslashes as escapes, so on Windows `C:\Users\...\Temp\.tmpX` became the drive-relative `C:Users...`, failed has_root(), and the tests got the settings or HOME path instead. Resolve with Os::current() so the options are split the way the host would split them; with only HOME set the Windows branch falls back to HOME, so expectations are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
bugbot run Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit a39bc39. Configure here.
|
Burn-down agent: Ready for review again at
Slack announcement not sent this run (the Slack send tool is unavailable to the agent); the next run retries. Generated by Claude Code |
Final review briefWhat it does. Agent mode and Risk: medium. It changes which directory global scan/patch/rollback touch for Maven users with a non-default setup. Default setups ( Look here
Verified
Changes I made: Open questions (non-blocking, from the PR description):
Auto-merge is armed, so an approval sends this straight to the merge queue. Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
Fixes #423
Root cause
m2_repo_path_with(crates/socket-patch-core/src/crawlers/maven_crawler.rs) picks the Maven local repository that agent mode and-gwork on. It doesn't match how Maven picks it:$M2_HOME/repository.M2_HOMEis the Maven install directory, and no Maven version keeps a local repository there.<localRepository>from the user's~/.m2/settings.xmlor the install'sconf/settings.xml, or-Dmaven.repo.localfromMAVEN_OPTS.HOMEoverUSERPROFILE, but Java'suser.home(which Maven uses) is the profile directory.In each case the crawler scans an empty or missing directory.
scan -greports 0 packages, androllback -gdrops the patch record while the real local repository stays patched.Plan
MAVEN_REPO_LOCAL, then-Dmaven.repo.localinMAVEN_OPTS, then<localRepository>in user settings, then in global settings ($MAVEN_HOME/$M2_HOMEconf/settings.xml), then<user.home>/.m2/repository. On Windows,user.homeisUSERPROFILE.Progress
e33d5b5: the lookup now follows Maven's order.20dd097rewrites the integration test that asserted$M2_HOME/repository.dec7a9breads<localRepository>as XML (CDATA, entities, not a profile property), takes-Duser.homefromMAVEN_OPTSonly, and drops the Maven variables from the CLI e2e children's environment.crawlers::maven_crawler::local_repo_testsfailed on the old resolver. The eighth (unusable settings fall back to the default) passed there too. All pass with the fix:cargo test -p socket-patch-core --lib maven_crawlerreports 71 passed.--test crawler_maven_e2epasses (28) and--test crawler_gradle_e2epasses (33).cargo fmt --all -- --checkandcargo clippy --workspace --all-features -- -D warningsare clean.5adf231: settings.xml is read FIFO-safely, which the crawler architecture test requires.cargo test -p socket-patch-core --all-features: 6932 passed. Five failed. One was the architecture guard, fixed in5adf231. The other four are chmod-based tests (copy_tree::relax_loop_must_not_traverse_symlinked_root,vlt_heal::an_unremovable_hidden_lock_keeps_every_store_entry,pypi_poetry::wire_write_failure_*,pypi_requirements::wire_failure_rolls_back_*) in files this PR doesn't touch. They fail only because this container runs as root, which ignores0o555.socket-patch-clitest suites. Compiling them ran out of disk in the container.448fbe0: fixes both Bugbot findings. A comment inside<localRepository>no longer leaks into the path (newsettings_local_repository_skips_comments, red before and green after), and the Maven crawler e2e harness clearsM2_HOME. Full CI is green on448fbe0and Bugbot found no issues.Review findings not fixed (
/code-review high)user.homestill prefers$HOMEover the passwd entry. That predates this PR (B66 tests pin it), and the e2e harnesses rely onHOMEfor isolation. Changing it is a separate decision.mavenLocal()shares this lookup, soMAVEN_OPTS -Dmaven.repo.localalso steers it. Gradle does readsettings.xmlthe same way..mvn/maven.config,-s/-gsinMAVEN_ARGS, and shell-literal quoting inMAVEN_OPTSaren't modelled. The lookup has no project context.JvmEnv::from_processre-reads up to two small settings files. That cost is negligible next to the crawl.https://claude.ai/code/session_011f9aeNoGBTiq4ogGfW9bp8
Note
Medium Risk
Changes core JVM cache path resolution used by global scan and patching; behavior is heavily tested but misconfiguration could still affect which repo is crawled.
Overview
Fixes #423 by replacing the Maven local-repo resolver so agent mode and
-gscan the same directory Maven uses, instead of wrongly treating$M2_HOME/repositoryas the cache.m2_repo_path_withnow follows Maven’s precedence:MAVEN_REPO_LOCAL, then-Dmaven.repo.localinMAVEN_ARGS/MAVEN_OPTS, then<localRepository>in user then globalsettings.xml(underMAVEN_HOME/M2_HOME), thenuser.home/.m2/repository. On Windows,user.homecomes fromUSERPROFILE, notHOME. New helpers parse settings XML (CDATA, entities,${…}interpolation, comments, ignoring profile properties namedlocalRepository) and read settings FIFO-safely.CLI JVM test isolation scrubs
MAVEN_OPTS,MAVEN_ARGS,MAVEN_HOME, andM2_HOMEso e2e runs don’t hit a developer’s real Maven config.docs/ecosystems.mddocuments the discovery order; integration tests andlocal_repo_testscover the regression triggers.Reviewed by Cursor Bugbot for commit a39bc39. Configure here.
Generated by Claude Code