An issue where the shotgun menu does not appear when using rez

I want to add rez as a field to the shotgrid software entity and configure Nook’s default settings with the rez package.
If you currently leave the tk-nuke field empty, the shotgun menu appears normally.


However, if you add the name of the rez package you want to use in the rez field, the shotgun menu does not appear.

In tk-multi-launchapp, yml was set to run ​​during the hook process. Below is the code content of


Copyright (c) 2013 Shotgun Software Inc.


This work is provided “AS IS” and subject to the Shotgun Pipeline Toolkit

Source Code License included in this distribution package. See LICENSE.

By accessing, using, copying or modifying this work you indicate your

agreement to the Shotgun Pipeline Toolkit Source Code License. All rights

not expressly granted therein are reserved by Shotgun Software Inc.

App Launch Hook

This hook is executed to launch the applications.

import os
import re
import sys
import subprocess
import tank

class AppLaunch(tank.Hook):
Hook to run an application.

def execute(self, app_path, app_args, version, engine_name, **kwargs):
    The execute functon of the hook will be called to start the required application
    :param app_path: (str) The path of the application executable
    :param app_args: (str) Any arguments the application may require
    :param version: (str) version of the application being run if set in the
        "versions" settings of the Launcher instance, otherwise None
    :param engine_name (str) The name of the engine associated with the
        software about to be launched.

    :returns: (dict) The two valid keys are 'command' (str) and 'return_code' (int).
    app_name = engine_name.split("-")[-1] #tk-nuke to nuke
    context = self.tank.context_from_path(self.tank.project_path)
    project = context.project = self.tank.shotgun
    packages = self.get_rez_packages(app_name,version,project)
        import rez as _
    except ImportError:
        rez_path = self.get_rez_module_root()
        rez_path = rez_path.decode('utf-8')
    from rez import resolved_context
    # command = '"{path}" {args} &'.format(path=app_path, args=app_args)
    command = 'start "App" "{path}" {args}'.format(path=app_path, args=app_args)
    if not packages:
        self.logger.debug('No rez packages were found. The default boot, instead.')
        return_code = os.system(command)
        return {'command': command, 'return_code': return_code}
        context = resolved_context.ResolvedContext(packages)
        proc = context.execute_shell(
            command = command,
            stdin = False,
            block = False
        return_code = 0
        return {'command': command,'return_code': return_code,}

def get_rez_packages(self,app_name,version,project):
    filter_dict = [['code','is',app_name.title()]
    packages ="Software",filter_dict,['sg_rez'])

    if packages: 
        packages =  packages[0]['sg_rez']

    if packages:
        packages = [ x for x in packages.split(",")] 
        packages = None
    return packages
def get_rez_module_root(self):

    command = 'rez-env rez -- echo %REZ_REZ_ROOT%'
    module_path, stderr = subprocess.Popen(
        command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).communicate()

    module_path = module_path.strip()

    if not stderr and module_path:
        return module_path

    return ''

I would be very grateful if you could help me.