Description
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
- Create a
package.py
for atest_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')
- Install the package to your package repository.
- Run
rez-env -- a_non_existent_executable
- 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
- Run
rez-env test_invalid_alias -- my_alias
- 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
- Added failing test in PowerShell alias calling non-existent command returns 0 exit code #1801
Expected behavior
A non-zero exit code is returned.
Actual behavior
A 0 exit code is returned.