--test_env=LD_LIBRARY_PATH not passed to tests on MacOS
See original GitHub issueI need to manipulate the LD_LIBRARY_PATH used by my test binaries. I tried using --test_env=LD_LIBRARY_PATH and --test_env=LD_LIBRARY_PATH=foo and neither were set in the environment when running the tests. Nor are DYLD_LIBRARY_PATH and most other DYLD_* values. Arbitrary other environment variables are correctly passed (–test_env=FOO=1, etc).
I can’t seem to find any code in bazel that is explicitly stripping these, but perhaps I’m missing something. Why is this happening? The docs state that --test_env can be used for this kind of stuff (explicitly listing --test_env=PATH as an example) - why would LD_LIBRARY_PATH be special?
I was able to confirm this with the following:
sh_binary(name = "runner", srcs = ["runner.sh"])
sh_test(name = "dummy", srcs=["runner.sh"])
#!/bin/bash
export
echo $LD_LIBRARY_PATH
$ blaze test :dummy --test_env=LD_LIBRARY_PATH=/foo --test_env=FOO=1 --run_under=:runner
Output:
...
declare -x FOO="1"
...
LD_LIBRARY_PATH is nowhere in that list and the value is empty.
$ bazel version
Build label: 0.6.1-homebrew
Build target: bazel-out/darwin_x86_64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Oct 6 02:36:58 2017 (1507257418)
Build timestamp: 1507257418
Build timestamp as int: 1507257418
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (6 by maintainers)
The problem does persist with
--incompatible_strict_action_env
and passing the variables via--action_env
.I poked around a little, and it seems that El Capitan and later strip LD_LIBRARY_PATH/DYLD_LIBRARY_PATH for executables in certain directories, including /bin. see: https://forums.developer.apple.com/thread/9233
I’m going to close this as a not-Bazel-related issue, but please comment if there’s something we should look into further.
Related to https://github.com/bazelbuild/bazel/issues/6648?
From memory I didn’t have that on and remember seeing the issue I linked at the time, and also do remember passing by
--action_env
as a test which was unsuccessful. Memory’s fallible though, so I’d have to check again.