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

[Bug] Infinite Symlink Expansion in external project (new_local_repository) #10693

Closed
firstprayer opened this issue Feb 2, 2020 · 2 comments
Closed

Comments

@firstprayer
Copy link

Description of the problem / feature request:

Encountering "Infinite symlink expansion" when integrating an external cmake project which has symlink.

ERROR: infinite symlink expansion detected
[start of symlink chain]
/Users/taiyuanz/Projects/faiss/faiss
/Users/taiyuanz/Projects/faiss
[end of symlink chain]
ERROR: Skipping '@faiss_lib//:faiss_lib': no such package '@faiss_lib//': Infinite symlink expansion
WARNING: Target pattern parsing failed.
ERROR: no such package '@faiss_lib//': Infinite symlink expansion
INFO: Elapsed time: 0.059s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
    Fetching @faiss_lib; Restarting.

I was expecting Bazel to be able to work around this symlink because cmake can handle it pretty well.

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

  1. The external project is https://github.com/facebookresearch/faiss. You can do a git clone to have a copy locally. Then you can follow the instruction on INSTALL.md to do ./configure and then make
  2. You can see the in the root of the project folder there's a symlink "faiss/ -> ./". This allows the developers of FAISS to write code like "#include <faiss/IndexFlat.h>" etc, even though IndexFlat.h is actually under the root directory
  3. To reproduce using bazel, we just need the following simple files:

WORKSPACE

# File //:WORKSPACE
workspace(name = "faiss_server")

# External libraries that don't use bazel.
new_local_repository(
    name = "faiss_lib",
    path = "/Users/taiyuanz/Projects/faiss/",
    build_file_content = """
cc_library(
    name = "faiss_lib",
    srcs = glob(
        ["*.o", "*.h"]
    ),
    visibility = ["//visibility:public"],
)
    """
)

Then you just run

bazel build @faiss_lib//:faiss_lib

Then you will see

ERROR: infinite symlink expansion detected
[start of symlink chain]
/Users/taiyuanz/Projects/faiss/faiss
/Users/taiyuanz/Projects/faiss
[end of symlink chain]
ERROR: Skipping '@faiss_lib//:faiss_lib': no such package '@faiss_lib//': Infinite symlink expansion
WARNING: Target pattern parsing failed.
ERROR: no such package '@faiss_lib//': Infinite symlink expansion
INFO: Elapsed time: 0.059s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
    Fetching @faiss_lib; Restarting.

What operating system are you running Bazel on?

Mac OS X Catalina

What's the output of bazel info release?

release 2.0.0

Have you found anything relevant by searching the web?

I have checked various discussions but haven't found anything similar to this issue.

Any other information, logs, or outputs that you want to share?

Not yet.

@irengrig
Copy link
Contributor

irengrig commented Feb 3, 2020

Hi @firstprayer, the reported problem describes Bazel designed behavior: recursive symlinks are not allowed. Bazel expands symlinks to track file changes for accurate incremental builds.
Similar problem: #2927

@jin
Copy link
Member

jin commented Feb 28, 2020

Closing as WAI and dupe.

@jin jin closed this as completed Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants