Inconsistent normalization of config paths can break handling of local packages path
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
- Windows 10
- Rez 2.114.1
- Rez python version: 3.7.9
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.
- Create a personal
~/.rezconfig.py, and add this to it:
import os
local_packages_path = '{0}/packages'.format(os.path.expanduser('~'))
- 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
- The path to the
packagesfolder in your home directory is included in the resulting output. - When using
rez-env --no-local, packages in your local packages path can still be included in the resolve.
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.