0

I've come across a python error similar to this while running genrules in my bazel setup.

The root cause of this error is that certain language environment variables are not set as expected, so files aren't being read with the correct encoding.

Setting

build --action_env="LANG=en_GB.UTF-8"
run --action_env="LANG=en_GB.UTF-8"
test --action_env="LANG=en_GB.UTF-8"

in my .bazelrc is a workaround, but feels somewhat hacky. What is the best way to configure bazel's language/locale settings for genrules?

JMAA
  • 1,730
  • 13
  • 24

1 Answers1

2

--action_dev/--test_env is the only way to pass in an environment variable. It can be specified in .bazelrc or be set as an argument to bazel command.

Alternatively, if you only need to set an env variable for a specific genrule, you can do that explicitly in your genrule. Note FOO=bar in cmd:

genrule(
    name = "foo",
    srcs = [],
    outs = ["foo.h"],
    cmd = "FOO=bar ./$(location create_foo.pl) > \"$@\"",
    tools = ["create_foo.pl"],
)
frizzby
  • 399
  • 1
  • 10