Skip to content

PowerShell alias calling non-existent command returns 0 exit code #1800

Open
@brycegbrazen

Description

@brycegbrazen

Running an alias using the Powershell shell plugin with rez-env doesn't return a failure exit code when attempting to run a non-existent aliased command in-line.

Environment

  • Windows 10
  • Rez 2.112.0
  • Rez python version 3.7.9

To Reproduce

  1. Create a package.py for a test_invalid_alias package with the following definition:
name = "test_invalid_alias"

version = "1.0.0"

build_command = ""

def commands():
    alias('my_alias', 'a_non_existent_executable')
  1. Install the package to your package repository.
  2. Run rez-env -- a_non_existent_executable
  3. Observe the following error message:
& : The term 'a_non_existent_executable' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\bryce.gattis\AppData\Local\Temp\rez_context_2bfjto0k\rez-shell.ps1:4 char:3
+ & a_non_existent_executable
+   ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (a_non_existent_executable:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
  1. Run rez-env test_invalid_alias -- my_alias
  2. Observe $LASTEXITCODE as being 0 instead of a non-zero exit code.

Use Case
This is currently happening and causing issues on our render farm. With Rez, we are creating aliases for python that map to whatever the DCC's version of python is. For example, the python alias for Houdini maps to hython.

The behavior observed via this issue is problematic when a specific machine doesn't have the correct version of Houdini installed on their machine. Rez will still use the alias (and expect that the corresponding software is installed where the Rez package is looking for it), but will not correctly return a non-zero exit code if the executable is not found.

This causes false positives on our render farm.

Related Issues/PRs

Expected behavior
A non-zero exit code is returned.

Actual behavior
A 0 exit code is returned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugos:windowsWindows-specificshellShell related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions