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

Error with use of $(rlocationpath) in Bazel 8.0.0 #24613

Closed
mortenmj opened this issue Dec 9, 2024 · 8 comments
Closed

Error with use of $(rlocationpath) in Bazel 8.0.0 #24613

mortenmj opened this issue Dec 9, 2024 · 8 comments
Assignees
Labels
P1 I'll work on this now. (Assignee required) team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: bug

Comments

@mortenmj
Copy link

mortenmj commented Dec 9, 2024

Description of the bug:

Some of our targets now throw the following error:

(11:12:14) ERROR: /workspace/infrastructure/lib/python/cogmono/auth/BUILD.bazel:57:20: in sh_binary rule //lib/python/cogmono/auth:auth_wheel_publish.publish: label '@@rules_python+//tools/publish:twine' in $(location) expression expands to more than one file, please use $(locations @@rules_python+//tools/publish:twine) instead.  Files (at most 5 shown) are: [rules_python+/tools/publish/_twine, rules_python+/tools/publish/rules_python_entry_point_twine.py]

(11:12:14) ERROR: /workspace/infrastructure/lib/python/cogmono/auth/BUILD.bazel:57:20: in env attribute of sh_binary rule //lib/python/cogmono/auth:auth_wheel_publish.publish: $(rlocationpath) not defined. Since this rule was created by the macro 'publish_to_snakepit', the error might have been caused by the macro implementation

(11:12:14) ERROR: /workspace/infrastructure/lib/python/cogmono/auth/BUILD.bazel:57:20: Analysis of target '//lib/python/cogmono/auth:auth_wheel_publish.publish' failed

I'll try to provide a minimal reproducer today, but wanted to log this error before Bazel 8 is released.

Edit: I guess the Bazel 8 ship has sailed

Which category does this issue belong to?

Bug/regression

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

Clone https://github.com/mortenmj/location_repro and run build //....
Build succeeds when running USE_BAZEL_VERSION=7.4.1 bazel build //... but fails when running USE_BAZEL_VERSION=8.0.0 bazel build //...

On Bazel 7, with rlocationpath, the TWINE_WRAPPER env var gets the value rules_python+/tools/publish/twine.
On Bazel 8, if updating to use rlocationpaths, the value is rules_python+/tools/publish/_twine rules_python+/tools/publish/rules_python_entry_point_twine.py.

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

release 8.0.0

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

b89ec43

Have you found anything relevant by searching the web?

No response

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

No response

@fmeum
Copy link
Collaborator

fmeum commented Dec 9, 2024

@bazel-io flag

@bazel-io bazel-io added the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Dec 9, 2024
@mortenmj mortenmj changed the title Error with use of $(location) in Bazel 8.0.0rc8 Error with use of $(rlocationpath) in Bazel 8.0.0rc8 Dec 9, 2024
@mortenmj mortenmj changed the title Error with use of $(rlocationpath) in Bazel 8.0.0rc8 Error with use of $(rlocationpath) in Bazel 8.0.0 Dec 9, 2024
@sgowroji sgowroji added the team-Local-Exec Issues and PRs for the Execution (Local) team label Dec 10, 2024
@meisterT meisterT added team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts and removed team-Local-Exec Issues and PRs for the Execution (Local) team labels Dec 10, 2024
@fmeum
Copy link
Collaborator

fmeum commented Dec 10, 2024

I think that this is just one more instance of #23200 and #20038 and #11820. I suggest we go with #11820 (comment).

@meteorcloudy It looks like 8.0.1 is planned already for the ignored directories fix, what do you think of including this fix in it as well?

@meteorcloudy
Copy link
Member

Yeah, we could include a fix for this problem, but I have little context on this issue, do you know who can help review the change?

@meteorcloudy
Copy link
Member

meteorcloudy commented Dec 10, 2024

Maybe @comius ?

@iancha1992
Copy link
Member

@bazel-io fork 8.1.0

@bazel-io bazel-io removed the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Dec 10, 2024
@meteorcloudy
Copy link
Member

meteorcloudy commented Dec 11, 2024

@bazel-io fork 8.0.1

@fmeum fmeum self-assigned this Dec 12, 2024
@fmeum fmeum added P1 I'll work on this now. (Assignee required) and removed untriaged labels Dec 12, 2024
fmeum added a commit to fmeum/bazel that referenced this issue Jan 9, 2025
Work towards bazelbuild#11820
Fixes bazelbuild#20038
Fixes bazelbuild#23200
Fixes bazelbuild#24613

RELNOTES: Extra targets provided to `ctx.expand_location` now expand to their executable (if any) instead of resulting in an error if they provide a number of files different from one.

RELNOTES[INC]: The `--incompatible_locations_prefers_executable` flag has been added and enabled, which makes it so that `ctx.expand_location` expands `$(locations :x)` to the executable of an extra target `:x` if it provides one and the number of files provided by it is not one.

Closes bazelbuild#24690.

PiperOrigin-RevId: 713453768
Change-Id: I0d6e052bc70deea029554ab722feb544f9597a23
(cherry picked from commit 457d248)
github-merge-queue bot pushed a commit that referenced this issue Jan 9, 2025
…24874)

Work towards #11820
Fixes #20038
Fixes #23200
Fixes #24613

RELNOTES: Extra targets provided to `ctx.expand_location` now expand to
their executable (if any) instead of resulting in an error if they
provide a number of files different from one.

RELNOTES[INC]: The `--incompatible_locations_prefers_executable` flag
has been added and enabled, which makes it so that `ctx.expand_location`
expands `$(locations :x)` to the executable of an extra target `:x` if
it provides one and the number of files provided by it is not one.

Closes #24690.

PiperOrigin-RevId: 713453768
Change-Id: I0d6e052bc70deea029554ab722feb544f9597a23 
(cherry picked from commit 457d248)

Fixes #24646
@iancha1992
Copy link
Member

A fix for this issue has been included in Bazel 8.0.1 RC1. Please test out the release candidate and report any issues as soon as possible.
If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=8.0.1rc1. Thanks!

@saraadams
Copy link
Contributor

A fix for this issue has been included in Bazel 8.0.1 RC1. Please test out the release candidate and report any issues as soon as possible. If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=8.0.1rc1. Thanks!

Tested just now and rc1 fixes the problem for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 I'll work on this now. (Assignee required) team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants