(this is me again :)
I'm trying to set DYLD_LIBRARY_PATH in env_info but conan doesn't propagate the variable to test_package (at least, can't check other dependencies).
Simple test:
https://gist.github.com/mikea/edc4a2b7921616c86fa2f46a5690c516
In main conanfile.py:
def package_info(self):
self.env_info.DYLD_PRINT_ENV = "1"
If you print environment in test program, you wouldn't see DYLD_PRINT_ENV defined (and it is not applied either)
I think the environment is not being correctly passed to the execution of the child process. Could you please try printing the environment in python inside the test() method launching the test?
If I add self.output.info(os.environ) to test method, then the output has DYLD_PRINT_ENV: u'DYLD_PRINT_ENV': u'1'
Those u prefixes worry me though, the rest of variables are not unicode:
'PAGER': 'less', 'TMUX_PANE': '%14'
Can this be the reason for not passing it through to os.system?
I've faced the same issue recently. it seems like new OSX security enhancements - DYLD* variables are no longer inherited. the following workaround worked:
env = RunEnvironment(self)
with tools.environment_append(env.vars);
self.run('DYLD_LIBRARY_PATH=%s ./test_package" % os.environ['DYLD_LIBRARY_PATH']
Yes, that makes sense, thanks for the tip @SSE4
@mikea if you please confirm this works, please tell me, and I will add it to the conan docs. Thanks!
@SSE4 Are you sure that you need the RunEvironment and the environment_append? This way doesn't work?
self.run('DYLD_LIBRARY_PATH=%s ./myexe" % os.environ['DYLD_LIBRARY_PATH']
@lasote RunEnvrionment sets DYLD_LIBRARY_PATH, so it's needed for sure
But you are setting it directly in the self.run command, 驴?
yep, you're setting it explicitly in command line, because it's not inherited from python to the test_package process.
So, why you need both the env and the command line one?
But the OP is setting the DYLD_LIBRARY_PATH explicitly as an env-var in its package recipe. The RunEnvironment is needed to automatically add dependencies "bin" folders to the DYLD_LIBRARY_PATH, even if those dependencies didn't declare the environment variable.
that's getting complicated...
lemme explain
Yes, but if the dependency has something like:
def package_info(self):
self.env_info.DYLD_LIBRARY_PATH= os.path.join(self.package_folder, "bin")
Then, you don't need 2 and 3, the env-var should already be applied to the consumer package. Am i missing something, @lasote?
That's my point @memsharded. The env vars should be automatically applied, if the exe is not inheriting the DYLD_LIBRARY_PATH then using the self.run('DYLD_LIBRARY_PATH=%s ./myexe" % os.environ['DYLD_LIBRARY_PATH']) should be enough.
But yes, if the requirements are not declaring the DYLD_LIBRARY_PATH you would need the RunEvironment helper to generate for you the "pointers" to the bin dirs.
@memsharded @lasote I can confirm that self.run('DYLD_LIBRARY_PATH=%s ./myexe" % os.environ['DYLD_LIBRARY_PATH']) propagates DYLD_LIBRARY_PATH path correctly. I have also confirmed that non-DYLD variables propagate correctly as well.
Thanks.
Obligatory SO link: https://stackoverflow.com/questions/35568122/why-isnt-dyld-library-path-being-propagated-here
Thanks, I've opened https://github.com/conan-io/docs/issues/339 to add some info in the docs
Documented: http://conanio.readthedocs.io/en/latest/howtos/shared/env_vars.html#using-shared-libraries-from-dependencies