-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Why does Bazel navigate symbolic links when finding BUILD files? #7057
Comments
/sub |
bump |
This is great question! I don't know for sure why Bazel does this. My theory is that following these symlinks lets Bazel track changes in them or in their target, and correctly rebuild rules that depend on the link (e.g. a genrule with Whether symlinks in the source tree are good practice or not is another question. (Especially if said source tree is also built on Windows, not just Linux.) @ulfjack : do you have any thoughts on this topic? |
Funny, I just discussed this with @buchgr. He was working on related problems, but I'm not sure what his current plan is. |
Is there a good story for why it shouldn't treat symlinks like files or directories? I'm not convinced that changing this will be less confusing overall. |
Well, I tried to tell one in the description of this ticket. It seems like the only use case for navigating a symbolic link is a hacky way to pull something into a workspace. This feels like an odd feature for Bazel to support. I'm not really sure what it means for Bazel to navigate links within a workspace ... it seems to just result in Bazel compiling and linking the same thing multiple times. In summary, I cannot see how symbolic links provide anything beyond the ability to shoot yourself in the foot. It seems out of character for the Bazel project to not have a strong opinion about such a thing. |
Related bug: #6350 |
/cc @philwo |
I see a usecase for following symlinks: Imagine having a complex build setup: for example, I use bazel for building swift, and the setup for having it up and running takes quiet some time and code (I have custom macros in order to avoid duplicating code all around in the BUILD files). Now, I want to take this custom setup and reuse it for building swift code located in multiple different repositories: the code will not be inside the workspace. One way I can do this is by having all the bazel setup in a submodule, and a symlink pointing to a folder one level up, that in each of the repositories contains different packages. This has another benefit: separation of concerns. The build setup is isolated from the code: the details of how to build the source code are isolated from the source code, which I think is good because gives the ability to change the build setup without modifying anything inside the source code files. If not in this way, how can I reuse a bazel setup to build code in multiple repositories? |
I would think you could use a workspace rule to pull in your custom macros, something like:
And then you would pull them into a BUILD file with:
|
Okey @crorvick, I did not think about that 😅 Thanks! |
bump |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale. |
This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please post |
Description of the problem / feature request:
Bazel navigates into symbolic links when searching for BUILD files. This can be divided into two scenarios:
Description of the problem / feature request:
Do not traverse symbolic links when looking for BUILD files in a workspace.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
A slightly more complex, but less contrived scenario:
Bazel is tripping over its
bazel-<project>
symbolic link in the above example after the parent directory is renamed. A confound in resolving this particular issue is that it adding/bazel-*
to the list of ignored file patterns by Git (or whatever VCS is used) is a reasonable thing to do since thebazel-<project>
link is not predictable from what is under Git's control.The text was updated successfully, but these errors were encountered: