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

bazel run with --run_under does not work with targets specifying current workspace #15530

Closed
oliverlee opened this issue May 19, 2022 · 1 comment
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug

Comments

@oliverlee
Copy link
Contributor

Description of the bug:

--run_under does not seem to accept targets specifying the current workspace:

$ bazel run //:run --run_under=@current//:wrapper
ERROR: Only a single target can be run. Your target pattern //:run expanded to the targets //:run, //:wrapper

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

--- BUILD.bazel
sh_binary(
    name = "run",
    srcs = ["run.sh"],
)

sh_binary(
    name = "wrapper",
    srcs = ["wrapper.sh"],
)

--- WORKSPACE.bazel
workspace(name = "current")

--- run.sh
#!/usr/bin/env bash
echo "I ran"

--- wrapper.sh
#!/usr/bin/env bash
echo "wrapping"
$@
echo "wrapped"

Which operating system are you running Bazel on?

macOS 11.16

What is the output of bazel info release?

release 5.1.1

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?

This similar issue: #7656

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

This works fine when using the abbreviation //

bazel run //:run --run_under=//:wrapper
INFO: Build option --run_under has changed, discarding analysis cache.
INFO: Analyzed 2 targets (0 packages loaded, 262 targets configured).
INFO: Found 2 targets...
INFO: Elapsed time: 0.612s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
wrapping
I ran
wrapped
@meteorcloudy meteorcloudy added P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. and removed untriaged team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website labels May 24, 2022
@Wyverald
Copy link
Member

Thanks for the report. This is due to @current not technically being the same repo as @. Very annoying little issue indeed, but it should be resolved by #14852, so I'll go ahead and close this.

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-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug
Projects
None yet
Development

No branches or pull requests

4 participants
@Wyverald @oliverlee @meteorcloudy and others