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

--test_env=LD_LIBRARY_PATH not passed to tests on MacOS #3921

Closed
benvanik opened this issue Oct 18, 2017 · 6 comments
Closed

--test_env=LD_LIBRARY_PATH not passed to tests on MacOS #3921

benvanik opened this issue Oct 18, 2017 · 6 comments
Assignees
Labels
more data needed P2 We'll consider working on this in future. (Assignee optional) platform: apple team-Local-Exec Issues and PRs for the Execution (Local) team

Comments

@benvanik
Copy link

I 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
@thundergolfer
Copy link
Contributor

@benvanik I think we just ran into this same problem. --test_env=LD_LIBRARY_PATH doesnt show up but --test_env=FOO=BAR does.

Did you find a good way to resolve your problem, or do you know why this issue hasn't seen any attention?

@thundergolfer
Copy link
Contributor

@dslomov Hey are you able to give any information on whether this is an actual bug in Bazel?

@aiuto aiuto added z-team-Apple Deprecated. Send to rules_apple, or label team-Rules-CPP + platform:apple untriaged labels Apr 15, 2019
@thundergolfer
Copy link
Contributor

thundergolfer commented Apr 16, 2019

LD_LIBRARY_PATH is actually present in env on OSTYPE=linux-gnu regardless of whether --test_env=LD_LIBRARY_PATH is passed.

So I would guess that this issue isn't with --test_env, but rather that something is wiping the variable on OSX and not touching it on Linux.

@aragos aragos added team-Local-Exec Issues and PRs for the Execution (Local) team platform: apple and removed z-team-Apple Deprecated. Send to rules_apple, or label team-Rules-CPP + platform:apple labels Apr 17, 2019
@jmmv jmmv added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Sep 11, 2019
@jmmv
Copy link
Contributor

jmmv commented Sep 11, 2019

I don't think this is related, but do you have --incompatible_strict_action_env enabled? Could you also try passing these variables via --action_env?

@thundergolfer
Copy link
Contributor

Related to #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.

@susinmotion
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more data needed P2 We'll consider working on this in future. (Assignee optional) platform: apple team-Local-Exec Issues and PRs for the Execution (Local) team
Projects
None yet
Development

No branches or pull requests

7 participants