bazelbuild / bazelbuild/bazel

`.short_path` is not usable for output artifacts in external repository

Open
#8,598 9 comments 1 reaction 0 assignees View on GitHub
not stale P4 team-Rules-API type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

If I create an artifact with

```
ctx.actions.declare_file("out")
```

In package `@l//lp`, its various paths will be as follows:

`.path`: `bazel-out/k8-fastbuild/bin/external/l/lp/out`
`.root.path`: `bazel-out/k8-fastbuild/bin`
`.short_path`: `../l/lp/out`

`.short_path` is not really usable: it's probably relative to the `bin` directory of rules in the main repository, but since that directory is not available anywhere (`ctx.bin_dir` yields `bazel-out/k8-fastbuild/bin`), there is not a lot I can do with it.

It's also not "relative to its root", which is what the documentation says.

(somewhat related to #3675)

/cc @haberman

Contributor guide

Open the contributing guide

Research direction

Start with the ctx.actions.declare_file artifact and the ctx.bin_dir entry point, comparing the reported .path, .root.path, and .short_path values for an external repository. Trace the documented “relative to its root” behavior and add coverage showing the expected usable path for this case.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.