AcademySoftwareFoundation / rez

An integrated package configuration, build and deployment system for software
https://rez.readthedocs.io
Apache License 2.0
941 stars 335 forks source link

Inconsistent normalization of config paths can break handling of local packages path #1768

Open nrusch opened 3 months ago

nrusch commented 3 months ago

When overriding "path-like" config values, slashes in paths are not consistently normalized to the current platform, depending on the presence of special patterns (specifically, ~).

When local_packages_path uses different path literals that point to the same path between site and user config files, this will break the value of config.nonlocal_packages_path, and prevent flags like --no-local from working correctly.

Environment

To Reproduce

This uses slash differences on Windows to demonstrate the issue, but I can imagine similar issues arising from the use of symlinked directories in config values.

Start with a default rez install.

  1. Create a personal ~/.rezconfig.py, and add this to it:
    import os
    local_packages_path = '{0}/packages'.format(os.path.expanduser('~'))
  2. Run this command:
    rez-python -c 'import rez.config; print("\n".join(rez.config.config.nonlocal_packages_path))'

Expected behavior The path to the packages folder in your home directory should not be included in the resulting output.

Actual behavior

This is because path normalization is currently only applied indirectly based on whether the path contains ~ (smoking gun in rez.utils.formatting.expanduser), and can thus cause inconsistent config behavior.