{"record":{"id":"d258009b972328f1","repo":"symfony/symfony","slug":"s-is-neither-an-enabled-bundle-nor-a-directory","errorCode":null,"errorMessage":"\"%s\" is neither an enabled bundle nor a directory.","messagePattern":"\"(.+?)\" is neither an enabled bundle nor a directory\\.","errorType":"console","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php","lineNumber":149,"sourceCode":"                $bundle = $kernel->getBundle($input->getArgument('bundle'));\n                $bundleDir = $bundle->getPath();\n                $transPaths = [is_dir($bundleDir.'/Resources/translations') ? $bundleDir.'/Resources/translations' : $bundleDir.'/translations'];\n                $codePaths = [is_dir($bundleDir.'/Resources/views') ? $bundleDir.'/Resources/views' : $bundleDir.'/templates'];\n                if ($this->defaultTransPath) {\n                    $transPaths[] = $this->defaultTransPath;\n                }\n                if ($this->defaultViewsPath) {\n                    $codePaths[] = $this->defaultViewsPath;\n                }\n            } catch (\\InvalidArgumentException) {\n                // such a bundle does not exist, so treat the argument as path\n                $path = $input->getArgument('bundle');\n\n                $transPaths = [$path.'/translations'];\n                $codePaths = [$path.'/templates'];\n\n                if (!is_dir($transPaths[0])) {\n                    throw new InvalidArgumentException(\\sprintf('\"%s\" is neither an enabled bundle nor a directory.', $transPaths[0]));\n                }\n            }\n        } elseif ($input->getOption('all')) {\n            foreach ($kernel->getBundles() as $bundle) {\n                $bundleDir = $bundle->getPath();\n                $transPaths[] = is_dir($bundleDir.'/Resources/translations') ? $bundleDir.'/Resources/translations' : $bundle->getPath().'/translations';\n                $codePaths[] = is_dir($bundleDir.'/Resources/views') ? $bundleDir.'/Resources/views' : $bundle->getPath().'/templates';\n            }\n        }\n\n        // Extract used messages\n        $extractedCatalogue = $this->extractMessages($locale, $codePaths);\n\n        // Load defined messages\n        $currentCatalogue = $this->loadCurrentMessages($locale, $transPaths);\n\n        // Merge defined and extracted messages to get all message ids\n        $mergeOperation = new MergeOperation($extractedCatalogue, $currentCatalogue);","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/symfony/symfony/blob/698e28026c22cf35d032cdb6e800db48b1535790/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php#L131-L167","documentation":"Thrown by `debug:translation` when the optional `bundle` argument does not resolve to a registered bundle (the kernel's `getBundle()` throws `InvalidArgumentException`) AND the same value treated as a filesystem path has no `translations/` subdirectory. The command tries the bundle registry first, then falls back to treating the argument as a directory path, and only throws when both fail.","triggerScenarios":"Running `php bin/console debug:translation en SomeBundle` where `SomeBundle` is not registered in the kernel, or `debug:translation en /path/to/something` where `/path/to/something/translations/` does not exist.","commonSituations":"Bundle name typo, bundle not enabled in `config/bundles.php`, bundle registered under a different alias (extension alias vs bundle class name), or pointing at a directory that lacks the expected `translations/` structure.","solutions":["Check `config/bundles.php` to confirm the bundle is registered and note its exact name.","If passing a path, ensure it contains a `translations/` subdirectory.","Run without the bundle argument to debug application-level translations in the default directory.","Use `--all` to scan all registered bundles instead of naming one."],"exampleFix":"// before\nphp bin/console debug:translation en AcmeDemo\n\n// after (correct bundle name or a real path)\nphp bin/console debug:translation en AcmeDemoBundle\n# or\nphp bin/console debug:translation en /full/path/with/translations","handlingStrategy":"validation","validationCode":"// Validate the bundle argument before scripting the command.\n$bundles = array_map(fn($b) => $b->getName(), $kernel->getBundles());\n$isBundle = in_array($arg, $bundles, true);\n$isDir = is_dir($arg.'/translations');\nif (!$isBundle && !$isDir) {\n    // neither bundle nor directory; reject early\n}","typeGuard":"function bundleOrDirIsValid(\\Symfony\\Component\\HttpKernel\\KernelInterface $kernel, string $arg): bool\n{\n    $names = array_map(fn($b) => $b->getName(), $kernel->getBundles());\n    return in_array($arg, $names, true) || is_dir($arg.'/translations');\n}","tryCatchPattern":"try {\n    $exit = $command->run($input, $output);\n} catch (\\Symfony\\Component\\Console\\Exception\\InvalidArgumentException $e) {\n    // list bundles or check the directory path\n}","preventionTips":["Keep `config/bundles.php` in sync with installed bundles.","When pointing at a directory, confirm the `translations/` subdirectory exists."],"tags":["symfony","console","translation","bundles","configuration"],"analyzedSha":"698e28026c22cf35d032cdb6e800db48b1535790","analyzedAt":"2026-08-06T23:40:49.025Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}