Description
If I set an alias in my package.py as follows :
wrapper_path = "{root}/bin/launcher.bat"
app_dir = r"c:/Program Files/Shotgun"
app_path = os.path.join(app_dir, "Shotgun.exe")
alias('sg', '"{}" "{}" "{}"'.format(wrapper_path, 'sg', app_path))
The alias errors when entering the rez env for the package.
At C:\Users\pmacdonald\AppData\Local\Temp\rez_context_pr3jy1mp\context.ps1:46 char:90
+ ... donald\packages\sg_desktop\2024.4.1-tl.1/bin/launcher.bat" sg "c:/Pro ...
+ ~~
Unexpected token 'sg' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken
Before you ask, this approach to creating an alias, which points to a wrapper launcher batch script, allows me to store the alias used to launch the application in an environment variable, which I can then later use to launch the same application via the same rez alias when jobs are executed on deadline. There may be better approaches to this, which may make this issue a moot point.
The batch script "launcher.bat" is as follows:
set REZ_USED_ALIAS=%1
for /f "tokens=1,* delims= " %%a in ("%*") do set ALL_BUT_FIRST=%%b
%ALL_BUT_FIRST%
It takes the first argument and stores it in REZ_USED_ALIAS, then executes the remaining arguments to launch the application.
Environment
- OS Windows 10
- Rez version Rez 3.0.0 from c:\rez\Lib\site-packages\rez (python 3.11)
- Rez python version Rez 3.0.0 from c:\rez\Lib\site-packages\rez (python 3.11)
To Reproduce
- Create a package with the alias as defined in the description above.
- Build package.
rez env -ci
- enter the env
rez env sg_desktop
Expected behavior
I asked chatgpt for a working alias, and it came up with this, which works :
function sg {
& ".\bin\launcher.bat" sg "c:\Program Files\Shotgun\Shotgun.exe" @args
}
This may be a breaking change for rez to implement as a new way of forming aliases under powershell, but it certainly appears to work for me if I create this alias manually in ps.
Actual behavior
Looking at the source of the error, rez appears to be defining the alias as :
function sg() { "c:\users\pmacdonald\packages\sg_desktop\2024.4.1-tl.1/bin/launcher.bat" sg "c:/Program Files/Shotgun\Shotgun.exe" @args }
This alias raises the error indicated in the description above.