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

cquery --output=files is not useful for external dependencies #17658

Closed
jscheid-ventana opened this issue Mar 3, 2023 · 2 comments
Closed

cquery --output=files is not useful for external dependencies #17658

jscheid-ventana opened this issue Mar 3, 2023 · 2 comments
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Configurability Issues for Configurability team type: feature request

Comments

@jscheid-ventana
Copy link

Description of the feature request:

With #15979 cquery --output=files provides a relative path to the output or source file. The feature request is to make the output as readily usable when the target is from an external dependency.

Bazel 6.0.0

% cat WORKSPACE
workspace(name = "com_example")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
% touch BUILD
% bazel cquery --output=files @bazel_tools//tools/build_defs/repo:git.bzl
Starting local Bazel server and connecting to it...
INFO: Analyzed target @bazel_tools//tools/build_defs/repo:git.bzl (1 packages loaded, 1 target configured).
INFO: Found 1 target...
external/bazel_tools/tools/build_defs/repo/git.bzl
INFO: Elapsed time: 3.607s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 0 total actions

There is no WORKSPACE-relative "external" directory.

I happen to know that I can currently use $(bazel info output_path)/.. to get the parent directory to "external", but that's arcane knowledge and isn't directly provided by the cquery feature.

What underlying problem are you trying to solve with this feature?

Have cquery --output=files behave consistently for all files known to bazel.

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

release 6.0.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

Linked issues and PRs associated with #15979

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

No response

@fmeum
Copy link
Collaborator

fmeum commented Mar 8, 2023

There are pros and cons to emitting relative paths: They are hermetic (don't differ between developer machines), but at the same slightly harder to use (require prefixing with $(bazel info execution_root) to be resolvable in general).

@jscheid-ventana What do you think, would prominently documenting the fact that the paths emitted by --output=files may have to be (and can always) be resolved relative to $(bazel info execution_root) resolve the issue for you?

@jscheid-ventana
Copy link
Author

would prominently documenting the fact that the paths emitted by --output=files may have to be (and can always) be resolved relative to $(bazel info execution_root) resolve the issue for you

Yes. Documentation would help clarify context for usage of output (versus some assumption that the bazel-out prefixes are relative to the helper symlinks, etc.) and seems to solve my problem: scripts can use a consistent path base for source, external, and output files.

@gregestren gregestren added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Mar 13, 2023
fweikert pushed a commit to fweikert/bazel that referenced this issue May 25, 2023
Fixes bazelbuild#17658

Closes bazelbuild#17721.

PiperOrigin-RevId: 517408960
Change-Id: I5a9a0ed82d457511796ee9f538ac86270fc4c16f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Configurability Issues for Configurability team type: feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants