{"record":{"id":"2381c924ac1ebc59","repo":"yiisoft/yii2","slug":"target-referenced-bundle-and-name-cannot","errorCode":null,"errorMessage":"Target '{$referenced[$bundle]}' and '$name' cannot contain the bundle '$bundle' at the same time.","messagePattern":"Target '(.+?)' and '\\$name' cannot contain the bundle '\\$bundle' at the same time\\.","errorType":"console","errorClass":"yii\\console\\Exception","httpStatus":null,"severity":"error","filePath":"framework/console/controllers/AssetController.php","lineNumber":310,"sourceCode":"            $this->registerBundle($bundles, $name, $registered);\n        }\n        $bundleOrders = array_combine(array_keys($registered), range(0, count($bundles) - 1));\n\n        // fill up the target which has empty 'depends'.\n        $referenced = [];\n        foreach ($targets as $name => $target) {\n            if (empty($target['depends'])) {\n                if (!isset($all)) {\n                    $all = $name;\n                } else {\n                    throw new Exception(\"Only one target can have empty 'depends' option. Found two now: $all, $name\");\n                }\n            } else {\n                foreach ($target['depends'] as $bundle) {\n                    if (!isset($referenced[$bundle])) {\n                        $referenced[$bundle] = $name;\n                    } else {\n                        throw new Exception(\"Target '{$referenced[$bundle]}' and '$name' cannot contain the bundle '$bundle' at the same time.\");\n                    }\n                }\n            }\n        }\n        if (isset($all)) {\n            $targets[$all]['depends'] = array_diff(array_keys($registered), array_keys($referenced));\n        }\n\n        // adjust the 'depends' order for each target according to the dependency order of bundles\n        // create an AssetBundle object for each target\n        foreach ($targets as $name => $target) {\n            if (!isset($target['basePath'])) {\n                throw new Exception(\"Please specify 'basePath' for the '$name' target.\");\n            }\n            if (!isset($target['baseUrl'])) {\n                throw new Exception(\"Please specify 'baseUrl' for the '$name' target.\");\n            }\n            usort($target['depends'], function ($a, $b) use ($bundleOrders) {","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/yiisoft/yii2/blob/66f00d18a29b520f85e8e8f1e32d1e7e7b556cac/framework/console/controllers/AssetController.php#L292-L328","documentation":"Error \"Target '{$referenced[$bundle]}' and '$name' cannot contain the bundle '$bundle' at the same time.\" thrown in yiisoft/yii2.","triggerScenarios":"Thrown at framework/console/controllers/AssetController.php:310 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"66f00d18a29b520f85e8e8f1e32d1e7e7b556cac","analyzedAt":"2026-08-17T05:17:23.470Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}