Skip to content

Accessing undefined env variable causes side-effect in unrelated package #2039

@vjankijevic

Description

@vjankijevic

Using env.MY_VARIABLE to access a non-existent variable in one package causes a RexUndefinedVariableError. This is expected behavior and can be caught in a try / except block. However, if another unrelated package's logic accesses the env's values using env.values() or similar afterwards, a second RexUndefinedVariableError is raised in that package due to the access to the variable in the first package. Order of operation is crucial here, as this obviously does not occur if packageB is resolved before packageA.

Environment

  • Linux Rocky 9 / macOS 15.7.1
  • Rez version 3.3.0 and older
  • Rez Python version 3.11.13 and older

To Reproduce

  1. Download the example packages.zip archive.
  2. Change directory into the extracted packages directory.
  3. Execute: REZ_PACKAGES_PATH=. rez-env packageA packageB

Expected behavior
No error should be thrown during packageB's commands execution, even though a non-existent variable was accessed in packageA's commands function earlier. The environment should resolve as expected.

Actual behavior
The environment fails to resolve due to the error.

Workaround
Use getenv("MY_VARIABLE") instead of env.MY_VARIABLE to get the variable value and check for existence.

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