Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buildifier cannot find .buildifier-tables.json when run from a subdirectory within the workspace. #1311

Open
dpleshakov opened this issue Dec 1, 2024 · 0 comments · May be fixed by #1312
Open

Comments

@dpleshakov
Copy link

dpleshakov commented Dec 1, 2024

Description:

Buildifier looks for .buildifier.json starting from the current directory and traversing up to the workspace root. However, the paths specified in .buildifier.json for Tables and AddTables are used "as-is," which can lead to issues when running buildifier from a subdirectory.

Example project structure:

root/
├── .buildifier.json
├── .buildifier-tables.json
├── foo/
│   └── BUILD.bazel
├── BUILD.bazel
└── WORKSPACE

.buildifier.json content:

{
  "AddTables": ".buildifier-tables.json"
}

Steps to reproduce:

  • If buildifier is run from the root directory (buildifier -r .), there is no issue.
  • If buildifier is run from the foo subdirectory (cd foo && buildifier), the following error occurs:
    buildifier: failed to parse .buildifier-tables.json for -add_tables: open .buildifier-tables.json: The system cannot find the file specified.
    
    In this case, buildifier successfully finds .buildifier.json, but cannot locate the .buildifier-tables.json file, even though it is in the same directory as .buildifier.json.

Examples:

I have created an example project to demonstrate the problem and validate a solution. You can find it here:

Expected behavior:

Buildifier should be able to find .buildifier-tables.json regardless of the directory from which it is run, or it should provide a way to resolve this issue without requiring a full path to the file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant