Skip to content

Conversation

@rickeylev
Copy link
Collaborator

When a file (instead of directory) was duplicated, it was incorrectly be treated as
a directory. The conflicting path was turned into a directory and all the files
were made child paths of it. In practice, this usually worked out OK still because
the conflicting file was an __init__.py file for a pkgutil-style namespace package,
which effectively converted it to an implicit namespace package.

I think this was introduced by #3448,
but am not 100% sure.

To fix, first check for exact path equality when merging conflicting paths. If the
candidate file has the same link_to_path as the grouping, then just link to that file
and skip any remaining files in the group. The rest of the group's files are skipped
because none of them can contribute links anymore:

  • If they have the same path, then they are ignored (first set wins)
  • If they are a sub-path, then it violates the preconditions of the group (all files
    in the group should be exact matches or sub-paths of a common prefix)
  • If they aren't under the common prefix, then it violates the preconditions of the
    group and are skipped.

@rickeylev rickeylev requested a review from aignas as a code owner December 13, 2025 20:07
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @rickeylev, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the virtual environment (venv) merging logic where individual files were erroneously processed as directories when conflicts arose. The core change introduces a precise path equality check to ensure that when a file's path exactly matches a conflicting entry, it is correctly linked as a file, overriding any directory-based interpretations. This prevents unintended behavior, such as accidental implicit namespace package creation. Alongside this fix, the PR also includes a substantial update to the documentation's Python dependencies, incorporating torch and its associated NVIDIA CUDA libraries, and refines existing test cases to validate the improved conflict resolution.

Highlights

  • Venv Conflict Resolution: Correctly handles conflicting virtual environment files, preventing files from being mistakenly treated as directories during merging, especially for __init__.py files.
  • Exact Path Matching: Introduces a precise check for exact path equality when resolving venv conflicts, ensuring that a file is directly linked if its path matches, and skipping other conflicting entries in the group.
  • Dependency Updates: Updates several Python dependencies in docs/requirements.txt and adds torch along with its associated NVIDIA CUDA libraries to the documentation build.
  • Test Refinements: Refactors test helpers and adds a specific test case to validate the new file-level conflict merging logic, ensuring the fix behaves as expected.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@rickeylev rickeylev changed the title fix: correctly merge conflicting venv files fix: merge conflicting paths when files (instead of dirs) are being linked Dec 13, 2025
@rickeylev rickeylev changed the title fix: merge conflicting paths when files (instead of dirs) are being linked fix: correctly merge conflicting paths when files (instead of dirs) are being linked Dec 13, 2025
@rickeylev rickeylev force-pushed the fix.conflict.merging.files branch from 97b9278 to 8a752a0 Compare December 13, 2025 20:11
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes an issue with merging conflicting venv files, particularly when a file is duplicated instead of a directory. The core logic change in python/private/venv_runfiles.bzl is sound, using rf_root_path == entry.link_to_path to handle direct file links and partition for more robust prefix matching. The refactoring of the tests in tests/venv_site_packages_libs/app_files_building/app_files_building_tests.bzl improves clarity and the new test case for conflicting files is a great addition. I've found one minor typo in a test comment. Overall, this is a good fix.

rickeylev and others added 2 commits December 14, 2025 12:21
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@rickeylev rickeylev enabled auto-merge December 14, 2025 20:22
@rickeylev rickeylev added this pull request to the merge queue Dec 14, 2025
Merged via the queue into bazel-contrib:main with commit e05cf00 Dec 14, 2025
4 checks passed
@rickeylev rickeylev deleted the fix.conflict.merging.files branch December 14, 2025 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants