-
Notifications
You must be signed in to change notification settings - Fork 1k
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] Environment.dumps() write prepended variable in reverse order. #17859
Comments
Hi @todorico It seems this is not a bug. You are reversing the order, the order in the profile is the opposite one than in the
So it is the same order as the one in the |
Hi @memsharded, Thanks for your response. My issue is that I don't control the order; I reuse the output of The problem arises when loading the serialized environment, but only if the original environment contains prepended values. Here's a code example to illustrate: # No prepended values, so no assertion error:
env = Environment()
env.define("DEFINED", "defined")
# env.prepend_path("PREPENDED", "prepend_0")
# env.prepend_path("PREPENDED", "prepend_1")
env.append_path("APPENDED", "append_0")
env.append_path("APPENDED", "append_1")
env_vars = env.vars(self)
profile_env = ProfileEnvironment.loads(env.dumps()).get_profile_env("*/*")
for var, profile_value in profile_env.vars(self).items():
assert env_vars.get(var) == profile_value, f"mismatch {env_vars.get(var)} != {profile_value}" # Uncommenting the prepended values causes an assertion error:
# assert env_vars.get(var) == profile_value, f"mismatch {env_vars.get(var)} != {profile_value}"
# AssertionError: mismatch prepend_1;prepend_0 != prepend_0;prepend_1
env = Environment()
env.define("DEFINED", "defined")
env.prepend_path("PREPENDED", "prepend_0")
env.prepend_path("PREPENDED", "prepend_1")
env.append_path("APPENDED", "append_0")
env.append_path("APPENDED", "append_1")
env_vars = env.vars(self)
profile_env = ProfileEnvironment.loads(env.dumps()).get_profile_env("*/*")
for var, profile_value in profile_env.vars(self).items():
assert env_vars.get(var) == profile_value, f"mismatch {env_vars.get(var)} != {profile_value}" It is surprising to me because I was expecting that the loading of the serialization of an environment would be the same as the environment, but it's not always true. |
I see, thanks for the feedback, I am having a look into it, I'll let you know asap. In any case, I'd like to raise the awareness that the dumped profile in command line output is exclusively informational.
Likewise the |
I am doing #17863 that will fix the prepend order for |
That's awesome, thank you very much ! |
Describe the bug
Environment details: Windows, Conan 2.12.2, Python 3.10.11
I use Environment.dumps() to create profiles that I can reuse later. However, I noticed that all variables that prepend paths using those generated profiles were in the reverse order.
How to reproduce it
Create a conanfile and generate a dummy environment:
Check the resulting environment script:
Now in comparison create a profile with the dumped environment:
If we use this profile to generate the environment instead of the environment script, the variable will be set in the wrong order:
The text was updated successfully, but these errors were encountered: