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

Query @sub//... of local_repository fails because of including @sub//bazel-subdir/ #10255

Closed
moroten opened this issue Nov 16, 2019 · 2 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request

Comments

@moroten
Copy link
Contributor

moroten commented Nov 16, 2019

Description of the problem / feature request:

Consider two repositories, toprepo which uses subrepo. subrepo is buildable of its own, which means that subrepo-checkout-dir/bazel-subrepo-checkout-dir will exist. When working in toprepo, bazel query @subrepo//... will fail when traversing @subrepo//bazel-subrepo-checkout-dir.

Feature requests: what underlying problem are you trying to solve with this feature?

By solving #7093 and #9080, it would be possible to add bazel-* to subrepo/.bazelignore and therefore avoid the problem. I will ignore bazel-* in all my future repositories, so consider adding bazel-* as a default built-in ignore.

Alternatively, teach local_repository to suppress bazel-* folders or limit the suppression to bazel-{bin,out,testlogs} and bazel-<dirname>.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

mkdir subdir
touch subdir/WORKSPACE
cat > WORKSPACE <<EOF
local_repository(
    name = "subrepo",
    path = "subdir",
)
EOF

(cd subdir && bazel build @bazel_tools//tools/build_defs/hash:sha256)
bazel build @subrepo//...

results in

ERROR: error loading package '@subrepo//bazel-subdir/external/bazel_tools/tools/python/runfiles': Every .bzl file must have a corresponding package, but '@subrepo//tools/python:private/defs.bzl' does not have one. Please create a BUILD file in the same or any parent directory. Note that this BUILD file does not need to do anything except exist.
INFO: Elapsed time: 0.712s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (9 packages loaded)
    currently loading: @subrepo//bazel-subdir/external/bazel_tools/tools/python

What operating system are you running Bazel on?

Linux (Ubuntu)

What's the output of bazel info release?

release 1.1.0

@SilverTux
Copy link

SilverTux commented Nov 20, 2019

Hi,

We have faced an issues similar to this and we figured it out that the problem is the bazel build ...:all command. What ... will do is recursively find bazel stuff in the current and child directories. Your first command bazel build @bazel_tools//tools/build_defs/hash:sha256 will create symlinks inside the subdir which will point to /home/user/.cache/... dir. I don't remember where but I've read somewhere that you shouldn't run bazel command inside that directory.
The solution is to use absolute references instead ... e.g.: bazel build @subrepo//:all.

Best regards,
SilverTux

@dslomov dslomov added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. untriaged labels Nov 25, 2019
@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
@philwo philwo added P3 We're not considering working on this, but happy to review a PR. (No assignee) type: feature request and removed untriaged labels Feb 8, 2021
@philwo philwo removed the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Nov 29, 2021
@sgowroji sgowroji added the stale Issues or PRs that are stale (no activity for 30 days) label Feb 10, 2023
@sgowroji
Copy link
Member

Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request
Projects
None yet
Development

No branches or pull requests

5 participants