bazelbuild / bazelbuild/bazel

File.root.path + File.short_path is not the same as File.path on files from external repositories

Open
#3,675 5 comments 0 reactions 0 assignees View on GitHub
not stale P3 team-Documentation team-ExternalDeps type: documentation (cleanup)
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

The path of file a file is documented as being made up of two parts the 'root' and the 'short_path'.
https://docs.bazel.build/versions/master/skylark/lib/File.html#path

These two values when joined according to the documentation should be the same as the path, but this is not the case when the File refers to a target in an external repository.

Example:
https://github.com/endobson/examples/tree/bazel-bug-root-relative

```
endobson@yggdrasil () ~/tmp/bazel-bug6 % bazel build //:test2 (0)
INFO: Reading 'startup' options from /Users/endobson/.bazelrc: --watchfs
WARNING: /Users/endobson/tmp/bazel-bug6/test.bzl:4:3: bazel-out/darwin_x86_64-fastbuild/bin/libbar.a.
WARNING: /Users/endobson/tmp/bazel-bug6/test.bzl:5:3: bazel-out/darwin_x86_64-fastbuild/bin.
WARNING: /Users/endobson/tmp/bazel-bug6/test.bzl:6:3: libbar.a.
INFO: Found 1 target...
Target //:test2 up-to-date (nothing to build)
INFO: Elapsed time: 1.362s, Critical Path: 0.00s
endobson@yggdrasil () ~/tmp/bazel-bug6 % bazel build //:test (0)
INFO: Reading 'startup' options from /Users/endobson/.bazelrc: --watchfs
WARNING: /Users/endobson/tmp/bazel-bug6/test.bzl:4:3: bazel-out/darwin_x86_64-fastbuild/bin/external/other/libfoo.a.
WARNING: /Users/endobson/tmp/bazel-bug6/test.bzl:5:3: bazel-out/darwin_x86_64-fastbuild/bin.
WARNING: /Users/endobson/tmp/bazel-bug6/test.bzl:6:3: ../other/libfoo.a.
INFO: Found 1 target...
Target //:test up-to-date (nothing to build)
INFO: Elapsed time: 0.123s, Critical Path: 0.00s
```

Contributor guide

Open the contributing guide

Research direction

Start with the linked example repository and the File.path, File.root.path, and File.short_path documentation. Reproduce the two Bazel builds and compare the values for local and external-repository files. Done means the documented relationship is made consistent or the documentation accurately reflects the external-repository behavior.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.