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

UNC paths with backslashes in {root} require sanitization for Houdini environment variables on Windows #1909

Open
viktor-hallen opened this issue Jan 24, 2025 · 2 comments
Labels
bug os:windows Windows-specific

Comments

@viktor-hallen
Copy link

When using {root} in a Rez package definition file (package.py), it resolves to a UNC path with backslashes () on Windows. This causes Houdini, and potentially other DCCs, to misinterpret environment variables (e.g., HOUDINI_PACKAGE_DIR) that contain UNC paths with backslashes, resulting in invalid paths.

Using hardcoded paths with forward slashes (/) works as expected. Manually adjusting {root} with expandvars and replacing backslashes with forward slashes resolves the issue, but it is unclear if this is an intentional behavior or a workaround for an edge case.

Environment

  • OS: Windows-10.0.19045 (Windows 10)
  • Rez version: 3.2.1
  • Rez Python version: Python 3.11.7
  • Houdini Version 20.5.332 (Py 3.11)

To Reproduce
Define the following package.py

def commands():
    # Normalization of the root path from windows to unix
    norm_root = expandvars("{root}").replace("\\", "/")

    # Windows format
    env.HOUDINI_OTLSCAN_PATH.set("{root}/otls")
    # Unix format
    env.HOUDINI_PACKAGE_DIR.set(f"{norm_root}/packages")

Run in terminal:

rez-env pkg_name -- python -c "import os; print('HOUDINI_PACKAGE_DIR:', os.environ.get('HOUDINI_PACKAGE_DIR')); print('HOUDINI_OTLSCAN_PATH:', os.environ.get('HOUDINI_OTLSCAN_PATH'))"

Terminal output:

HOUDINI_PACKAGE_DIR: //server/rez/pkg_name/packages
HOUDINI_OTLSCAN_PATH: \\server\rez\pkg_name\otls

Expected behavior
Houdini fails to recognize HOUDINI_PACKAGE_DIR when {root} resolves to a UNC path with backslashes (). The resolved path is printed as:
\\server\rez\pkg_name\packages

Houdini does not accept this format for UNC paths. However, manually using forward slashes works.

But Houdini does not accept this format for UNC paths. However, manually using forward slashes works:
env.HOUDINI_PACKAGE_DIR.set("//server/rez/pkg-name/packages")

The workaround to sanitize the path that currently worked was:
env.HOUDINI_PACKAGE_DIR.set(expandvars("{root}/packages").replace("\\", "/"))

Actual behavior
Houdini should correctly interpret HOUDINI_PACKAGE_DIR even if {root} resolves to a UNC path, regardless of the type of slashes (\ or /).
While this may not strictly be a bug in Rez, it highlights unexpected behavior that can cause compatibility issues with Houdini and potentially other DCCs.

Regression
Unknown if this issue existed in earlier versions of Rez or Python. Also havent tried earlier versions of Houdini.

Additional Context*
It seems like Houdini requires forward slashes for UNC paths, even on Windows.
Another user reported a similar issue when installing Quixel Bridge through Rez. The root directory resolved with backslashes, and Houdini complained about an invalid package directory.
@JeanChristopheMorinPerso mentioned that Rez handles path normalization, but this does not seem sufficient for UNC paths on Windows in this specific case.

@viktor-hallen viktor-hallen changed the title UNC Paths with Backslashes in {root} Require Sanitization for Houdini Environment Variables on Windows UNC paths with backslashes in {root} require sanitization for Houdini environment variables on Windows Jan 24, 2025
@JeanChristopheMorinPerso
Copy link
Member

Thanks @viktor-hallen . Would #1856 solve your issue?

@JeanChristopheMorinPerso JeanChristopheMorinPerso added the os:windows Windows-specific label Jan 26, 2025
@JeanChristopheMorinPerso
Copy link
Member

Potentially related to #1438

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