-
Notifications
You must be signed in to change notification settings - Fork 993
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
Clean repeated entries in PATH after vcvars call #3598
Clean repeated entries in PATH after vcvars call #3598
Conversation
conans/test/util/tools_test.py
Outdated
for repeated in repeated_keys: | ||
if previous_path.count(repeated) < 2: | ||
# If the entry was already repeated before calling "tools.vcvars" we keep it | ||
raise AssertionError("The key '%s' was not repeated previously but now it is" % repeated) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use self.fail("....")
instead.
conans/client/tools/win.py
Outdated
tmp = value[:-(len(old_value) + 1)].split(os.pathsep) | ||
if name_var.lower() == "path": | ||
# vcvars doesn't look if previous paths are already set so clean the repeated to avoid | ||
# max path (or any other list env var) len issues: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be just one line:
new_env[name_var] = {v.lower(): v for v in tmp}.values()
conans/test/util/tools_test.py
Outdated
new_values.append(i) | ||
else: | ||
repeated_keys.append(i) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is working as expected. We are appending a path
(lowercase) variable to os.environ
and then we are working with the PATH
(uppercase) one. I think that I need here, at least, a self.assertTrue(len(repeated_keys) != 0)
check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os.environ
is not case sensitive.
Thanks for the review, I simplified a lot how it is doing the deduplication. |
* Clean repeated * only the path * fixed test * Simplified path dedup
To clarify, there was no bug in Conan. vcvars prepends new variables to the PATH, but without looking if the entries in the path are or not already set with the same value there. With some recipes manipulating the environment, sometimes the max chars for PATHS is reached. So with this PR, the
vcvars_dict
will remove repeated entries in the PATH.Changelog: Feature: Clean repeated entries in the
PATH
whenvcvars
is run, mitigating the max size of the env var issues.