-
Notifications
You must be signed in to change notification settings - Fork 994
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
[bug]buildenv entries with ampersand not added correctly to package build environment #17611
Comments
Hi @tb-hh-si thanks a lot for your report While this is a bit confusing, and we're looking if changing the behaviour to be less suprissing would be feasible, for now this is expected behaviour, Conan right now gives precedence to the latest declared environment. If you define env_test without a scope before the consumer scoped ones, this will work around the issue for now, and you should see the expected priority, let me know if this helps |
Hi @AbrilRBS thanks for the reply. Could you elaborate on the precedence rules? So for instance if I have multiple definitions do I have to group them together like this?`
|
Also: does this behavior only apply for the buildenv sections? Or also for settings/options/conf? And is the syntax treated differently when using This doesn't work as I expected:
But this works in my tests:
And explicitly using package names also works for me:
|
To give some context:
This means that in practice, yes, confs using the same pattern should be together in profiles, and not interleaved with other confs.
In the last case, it doesn't work as you say, the following test passes: def test_profile_buildenv_patterns():
profile = textwrap.dedent("""\
[buildenv]
# unrelated setting; only for this package
mypackage/*:unrelated_env=test
# setting for dependencies
env_test=dependency
# override setting for this package
mypackage/*:env_test=package
""")
current_profile_path = os.path.join(temp_folder(), "default")
save(current_profile_path, profile)
profile_loader = ProfileLoader(cache_folder=temp_folder()) # If not used cache, will not error
profile = profile_loader.load_profile(current_profile_path)
buildenv = profile.buildenv
env = buildenv.get_profile_env(RecipeReference("mypackage", "1.0"), is_consumer=True)
text = env.dumps()
assert "unrelated_env=test" in text
assert "env_test=dependency" in text Proving that as |
Describe the bug
Environment: Conan 2.11, Linux (WSL)
Description:
When I define a buildenv entry in a profile for all dependencies (
env_test=dependency
) and then override it with the ampersand syntax for my package (&:env_test=package
) then conan will generate a different build-environment shell script for dependencies and my package. As expected.But when I add an additional entry just for my local package (
&:unrelated_env=test
) the incorrect value is generated into the build-environment of my package forenv_test
.How to reproduce it
profile_test.txt
See this example:
Expectation is that
env_test
is "package" for my package and "dependency" for all dependencies. But it's not.It works as expected if:
&:unrelated_env
linemypackage/*:unrelated_env=test
syntax instead.unrelated_env=
&:unrelated_env=test
The text was updated successfully, but these errors were encountered: