bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
22.97k stars 4.03k forks source link

`java_binary`'s `env` has no effect with Bazel@HEAD #19115

Closed fmeum closed 1 year ago

fmeum commented 1 year ago

Description of the bug:

java_binary's env attribute is ignored when the binary is run with bazel run.

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

# Foo.java
public class Foo {
  public static void main(String[] args) {
    System.out.println("Hello, " + System.getenv("MY_NAME") + "!");
  }
}

# BUILD
java_binary(
    name = "Foo",
    srcs = ["Foo.java"],
    env = {"MY_NAME": "Bazel"},
    main_class = "Foo",
)
$ USE_BAZEL_VERSION=6.3.0 bazel run //:foo
...
Hello, Bazel!
$ USE_BAZEL_VERSION=1f0f6670088bcd7b6d6ded4b32c6eedc7a9027d9 bazel run //:Foo
...
Hello, null!

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

1f0f6670088bcd7b6d6ded4b32c6eedc7a9027d9

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

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No response

Have you found anything relevant by searching the web?

No response

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

It looks like the Starlark implementation of java_binary doesn't return RunEnvironmentInfo.

fmeum commented 1 year ago

CC @hvadehra

hvadehra commented 1 year ago

I'll push out a fix soon.