Skip to content

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

Open
@viktor-hallen

Description

@viktor-hallen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions