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

Windows: new_local_repository doesn't get re-fetched after file changing #3374

Open
meteorcloudy opened this Issue Jul 13, 2017 · 4 comments

Comments

@meteorcloudy
Copy link
Member

meteorcloudy commented Jul 13, 2017

A simple reproduce:

$ tree .
.
├── A
│   └── bin.py
└── B
    ├── BUILD # empty
    └── WORKSPACE

$ cat A/bin.py
print("Hello World")

$ cat B/WORKSPACE
new_local_repository(
  name = "A",
  path = "C:/tools/msys64/home/pcloudy/workspace/my_tests/new_local_repository_test/A",
  build_file_content = """
py_binary(
  name = "bin",
  srcs = ["bin.py"],
)
  """,
)

$ cd B/

$ bazel build @A//:bin
INFO: Analysed target @A//:bin.
INFO: Found 1 target...
Target @A//:bin up-to-date:
  C:/tmp/_bazel_pcloudy/us9pue2o/execroot/__main__/bazel-out/msvc_x64-fastbuild/bin/external/A/bin
INFO: Elapsed time: 1.497s, Critical Path: 0.31s
INFO: Build completed successfully, 7 total actions

$ ./bazel-bin/external/A/bin
Hello World

$ echo "print(\"Hi\")" > ../A/bin.py

$ bazel build @A//:bin
INFO: Analysed target @A//:bin.
INFO: Found 1 target...
Target @A//:bin up-to-date:
  C:/tmp/_bazel_pcloudy/us9pue2o/execroot/__main__/bazel-out/msvc_x64-fastbuild/bin/external/A/bin
INFO: Elapsed time: 0.433s, Critical Path: 0.01s
INFO: Build completed successfully, 1 total action

$ ./bazel-bin/external/A/bin    # Should print "Hi"
Hello World    

As far as I know, local repository should be re-fetched every time.

A few things I noticed:

  • bazel clean will trigger a re-fetch
  • bazel shutdown will trigger a re-fetch
  • This only happens on Windows.
  • A bug in both 0.5.2 and HEAD
@meteorcloudy

This comment has been minimized.

Copy link
Member

meteorcloudy commented Jul 13, 2017

FYI, @kchodorow , in case you have some idea why this is happening.

@meteorcloudy

This comment has been minimized.

Copy link
Member

meteorcloudy commented Jul 13, 2017

I believe the root cause is again because symlinking on file is copy on Windows.
See here

  public static boolean symlinkLocalRepositoryContents(
      Path repositoryDirectory, Path targetDirectory)
      throws RepositoryFunctionException {
    try {
      FileSystemUtils.createDirectoryAndParents(repositoryDirectory);
      for (Path target : targetDirectory.getDirectoryEntries()) {
        Path symlinkPath = repositoryDirectory.getRelative(target.getBaseName());
        createSymbolicLink(symlinkPath, target);
      }
    } catch (IOException e) {
      throw new RepositoryFunctionException(e, Transience.TRANSIENT);
    }

    return true;
  }

If target is a file, it would be a copy.

But I don't understand fully yet is when will a local repository get re-fetched. It doesn't check the marker data AFAIK.

@laszlocsomor

This comment has been minimized.

Copy link
Contributor

laszlocsomor commented May 2, 2018

Is this bug fixed?

@laszlocsomor

This comment has been minimized.

Copy link
Contributor

laszlocsomor commented Oct 16, 2018

This could be related to #6351

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment