Description
I'm receiving an error when attempting to launched a detached shell with Powershell (5.0 and 7.0+) through the ResolvedContext.execute_shell
method.
Traceback (most recent call last):
File "C:/Users/n.shankar-noble.mull/AppData/Roaming/JetBrains/PyCharmCE2020.3/scratches/scratch_17.py", line 12, in <module>
block=True,
File "C:\opt\rez\Lib\site-packages\rez\resolved_context.py", line 1045, in _check
return fn(self, *nargs, **kwargs)
File "C:\opt\rez\Lib\site-packages\rez\resolved_context.py", line 1460, in execute_shell
**Popen_args)
File "C:\opt\rez\Lib\site-packages\rezplugins\shell\_utils\powershell_base.py", line 223, in spawn_shell
p = Popen(cmd, env=env, **Popen_args)
File "C:\opt\rez\Lib\site-packages\rez\utils\execution.py", line 91, in __init__
super(Popen, self).__init__(args, **kwargs)
File "C:\Python374\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Python374\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
Printing the cmd
executed by the shell plugin (in PowershellBase
) it doesn't seem to be running a valid Start-Process command:
['START', '-NoExit', 'c:\\program files\\powershell\\7\\pwsh.exe', '-NoLogo', '-File', 'C:\\Users\\NSHANK~1.MUL\\AppData\\Local\\Temp\\rez_context_7_3vs3yk\\rez-shell.ps1']
The -NoExit flag appears to be in the wrong place and believe the list of pwsh.exe arguments need to be passed as a string list through the -ArgumentList flag of Start-Process.
Running a non-detached shell with Powershell is working without issue.
Environment
- OS: Windows 10
- Rez version: 2.111.3
- Rez python version: Python 3.7.4
To Reproduce
Execute the following Python code with rez-python
:
import os
from rez.resolved_context import ResolvedContext
context = ResolvedContext(['python'])
returncode, stdout, stderr = context.execute_shell(
parent_environ=os.environ.copy(),
shell="pwsh",
detached=True,
block=True,
)
Expected behavior
Expected behaviour is that a new Powershell window would be opened in the ResolvedContext.
Actual behavior
The error listed above, with no shell launched.