Repository navigation
Warn when VCS file discovery cannot find its executable - #1570
RonnyPfannschmidt merged 6 commits into
Conversation
RonnyPfannschmidt
left a comment
There was a problem hiding this comment.
Written by Claude Opus 5.5 via Claude Code for mayankdhingra02; I prompted it, it did the work, I read it.
Thanks for picking this up. The diagnostic fills a real gap, and the tests cover the tricky bits (worktree marker, nested markers, ignored roots). A few details that slipped through:
- In the most common case the new warning doesn't fire: a project versioned by setuptools-scm,
.gitpresent,gitmissing. Inference fails first,ScmEggInfoMixin.find_sourcesentersscm_search_known_failed(), andfind_filesreturns before reaching the finders, so the #1540 warning shows instead. Worth stating in the docs paragraph, or covering that path. (Traced through the code, not run.) Fixes #1404would close the issue. The issue also asks about an error or a config option, and about frontends that hide log output.Refs #1404fits better unless those are out of scope._file_finders/_jj.pyhas the same silentexcept OSError, so.jjcould get the same treatment.- The
attempteddedup infind_filesapplies to every finder in both groups, which is wider than the issue. Please call it out in the description.
| """) | ||
| (cwd / "dist").mkdir(exist_ok=True) | ||
| return run([sys.executable, "-c", code], cwd).stdout | ||
| result = run([sys.executable, "-c", code], cwd) |
There was a problem hiding this comment.
for correct interleaving this should use the subprocess constant that sets stderr to stdout
RonnyPfannschmidt
left a comment
There was a problem hiding this comment.
Written by Claude Opus 5.5 via Claude Code for mayankdhingra02; I prompted it, it did the work, I read it.
Sorry, I should have caught these in my first pass instead of sending you a second round. Thanks for working through the first one so quickly.
1. False warning when a colocated jj+git checkout has only one tool installed
find_files tries the finders one after another. Each backend logs its missing-command warning as soon as the command fails, even if a later finder then lists the files. Installed entry points come back in the order .git, .jj. So in a colocated checkout (.git and .jj at the root, the default for jj git init now) with git missing and jj present, you get:
WARNING:vcs_versioning.file_finder:cannot list tracked files for .git in …/repo because the Git executable was not found
['…/repo/sub/a.py']
The warning says files are missing, but the result is complete. This was reproduced against the PR head with a stub jj on PATH.
A possible fix: the backends record the missing command instead of logging it, and find_files logs what was recorded only if no finder returned results. That also stops the warning depending on entry-point order. A test with two markers at the same root, one tool missing and the other working, would cover it.
2. _build_sdist hides the build output when the build fails
With check=True, a failed build raises CalledProcessError, and pytest doesn't show the captured build output then, which is exactly what you need to debug it. It would be better to keep vcs_versioning._run_cmd.run and check .stdout and .stderr, or to add a way for run to merge the two streams. (This was traced through the code, not run.)
Note: switching to plain subprocess.run also drops the environment cleanup run does (no_git_env, avoid_pip_isolation, LC_ALL). That doesn't matter for this test, but keeping run gets it back for free.
|
i will fix the hg install issues on main as they are unrelated to this |
|
thanks! |
Refs #1404.
Warn when file discovery finds Git, Mercurial, or Jujutsu metadata but its executable is missing and no registered finder can return tracked files. Diagnostics are deferred until all finders have been tried, so colocated Git/Jujutsu checkouts stay quiet when either working tool supplies the file list. Direct backend calls retain their existing warning behavior.
The diagnostic uses the nearest checkout, respects ignored roots, and handles missing-command errors without a filename. Finder deduplication applies across both primary and fallback entry-point groups. When version inference has already failed, discovery short-circuits with the existing “file discovery is suppressed” warning instead.
The sdist integration helper uses the existing environment-sanitizing command wrapper, with opt-in merged stdout/stderr. Failed builds expose their complete transcript, preserving output order. Tests cover both missing-tool choices and finder orders, unsuccessful discovery, collector cleanup, command environment cleanup, and a real failed build.
Validation for the latest follow-up on macOS/Python 3.12.9:
uv run pytest -n12 --basetemp=<short-task-local-directory>: 901 passed, 76 skipped, 1 expected failure. A short directory avoids macOS GPG socket-path limits; network access was enabled for the PyPI integration tests.pre-commit run --all-fileschecks anduv run mkdocs build --clean --strictpassed.Mercurial and Jujutsu executables were unavailable locally. The new colocated-checkout tests use a real Git repository with stubbed Jujutsu command responses; they do not establish interoperability with a live Jujutsu installation. Other full-suite skips cover optional tools, platform and filesystem cases; the ownership test retains its expected failure without passwordless sudo.
Hosted CI also encountered runner setup failures before executing tests: Python 3.8/3.9 are unavailable on its Ubuntu 26.04 image, and several jobs cannot find
hg. These failures are outside the changed file-discovery code; the corresponding jobs remain unverified.Codex helped reproduce and implement the change, with a separate review of the final diff.