Skip to content
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

REZ_USED_IMPLICIT_PACKAGES tilde expansion on windows #1717

Open
cfxegbert opened this issue Apr 11, 2024 · 2 comments
Open

REZ_USED_IMPLICIT_PACKAGES tilde expansion on windows #1717

cfxegbert opened this issue Apr 11, 2024 · 2 comments
Labels
bug os:windows Windows-specific

Comments

@cfxegbert
Copy link
Contributor

cfxegbert commented Apr 11, 2024

On Windows the first tilde on the REZ_USED_IMPLICIT_PACKAGES is being expanded to %HOMEDRIVE%%HOMEPATH%. This is using the default config which under rez-3.x is using PowerShell as the default shell. I know Microsoft is changing the behavior of ~ in PowerShell.

Environment

  • windows-10.0.19044.SP0
  • rez 3.1.0
  • Rez python version 3.10.10

To Reproduce

  1. rez-env
  2. Get-ChildItem -Path Env:\REZ_USED_IMPLICIT_PACKAGES

Expected behavior

REZ_USED_IMPLICIT_PACKAGES="~platform==windows ~arch==AMD64 ~os=windows-10.0.19044.SP0"

Actual behavior

REZ_USED_IMPLICIT_PACKAGES="C:\Users\platform==windows ~arch==AMD64 ~os==windows-10.0.19044.SP0"

@cfxegbert cfxegbert added the bug label Apr 11, 2024
@JeanChristopheMorinPerso JeanChristopheMorinPerso added the os:windows Windows-specific label Apr 13, 2024
@cfxegbert
Copy link
Contributor Author

cfxegbert commented May 17, 2024

It ends up this is how os.path.expanduser works on windows. On unix if there is a string that is not a path separator after ~ it check for the existence of the user, on windows if the user isn't the current user it just blindly changes ~ to 'USERPROFILE'.

Looks like I can fix this by changing https://github.com/AcademySoftwareFoundation/rez/blob/main/src/rez/resolved_context.py#L1982 to

executor.setenv("REZ_USED_IMPLICIT_PACKAGES", EscapedString(implicit_str, is_literal=True))

Trying to figure out if I should use EscapedString on all the REZ_USED variables

@JeanChristopheMorinPerso
Copy link
Member

It could make sense yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug os:windows Windows-specific
Projects
None yet
Development

No branches or pull requests

2 participants