{"record":{"id":"05efd74e14a5d7a2","repo":"composer/composer","slug":"invalid-stability-provided-s-must-be-one-of-s","errorCode":null,"errorMessage":"Invalid stability provided (%s), must be one of: stable, RC, beta, alpha, dev","messagePattern":"Invalid stability provided \\((.+?)\\), must be one of: stable, RC, beta, alpha, dev","errorType":"validation","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Composer/Command/CreateProjectCommand.php","lineNumber":411,"sourceCode":"            if (!$fs->isDirEmpty($directory)) {\n                throw new \\InvalidArgumentException('Project directory \"'.$directory.'\" is not empty.');\n            }\n        }\n\n        if (null === $stability) {\n            if (null === $packageVersion) {\n                $stability = 'stable';\n            } elseif (Preg::isMatchStrictGroups('{^[^,\\s]*?@('.implode('|', array_keys(BasePackage::STABILITIES)).')$}i', $packageVersion, $match)) {\n                $stability = $match[1];\n            } else {\n                $stability = VersionParser::parseStability($packageVersion);\n            }\n        }\n\n        $stability = VersionParser::normalizeStability($stability);\n\n        if (!isset(BasePackage::STABILITIES[$stability])) {\n            throw new \\InvalidArgumentException('Invalid stability provided ('.$stability.'), must be one of: '.implode(', ', array_keys(BasePackage::STABILITIES)));\n        }\n\n        $composer = $this->createComposerInstance($input, $io, $config->all(), $disablePlugins, $disableScripts);\n        $config = $composer->getConfig();\n        // set the base dir here again on the new config instance, as otherwise in case the vendor dir is defined in an env var for example it would still override the value set above by $config->all()\n        $config->setBaseDir($directory);\n        $rm = $composer->getRepositoryManager();\n\n        $repositorySet = new RepositorySet($stability);\n        if (null === $repositories) {\n            $repositorySet->addRepository(new CompositeRepository(RepositoryFactory::defaultRepos($io, $config, $rm)));\n        } else {\n            foreach ($repositories as $repo) {\n                $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);\n                if (\n                    (isset($repoConfig['packagist']) && $repoConfig === ['packagist' => false])\n                    || (isset($repoConfig['packagist.org']) && $repoConfig === ['packagist.org' => false])\n                ) {","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/composer/composer/blob/c435d285c9120efdca35696769c72ea9fdcc0466/src/Composer/Command/CreateProjectCommand.php#L393-L429","documentation":"Thrown by CreateProjectCommand::installRootProject() as an InvalidArgumentException when the requested stability (after normalization) is not one of the keys in BasePackage::STABILITIES (stable, RC, beta, alpha, dev). Stability can come from --stability option, be derived from the version constraint, or default to 'stable'.","triggerScenarios":"Passing `--stability=production`, `--stability=testing`, or a version string whose @stability suffix maps to an unknown token. Also if a custom/translated stability word is supplied.","commonSituations":"Confusing Composer stability terms with semantic-release terms (e.g. 'production'), typos like '--stability=devl', or inheriting stability from a malformed version constraint.","solutions":["Use one of the allowed values: `composer create-project vendor/project --stability=beta`.","Omit --stability and pin via the version argument instead (e.g. `vendor/project:^2@dev`).","For latest dev work use `--stability=dev`."],"exampleFix":"// before\ncomposer create-project vendor/project --stability=production\n// after\ncomposer create-project vendor/project --stability=stable","handlingStrategy":"validation","validationCode":"$allowed = ['stable','rc','beta','alpha','dev'];\nif (!in_array(strtolower((string)$stability), $allowed, true)) {\n    fwrite(STDERR, \"Invalid stability; use one of: \".implode(', ',$allowed).\"\\n\"); exit(1);\n}","typeGuard":"function isStabilityValid(string $stability): bool {\n    return in_array(strtolower($stability), ['stable','rc','beta','alpha','dev'], true);\n}","tryCatchPattern":null,"preventionTips":["Restrict --stability to the five Composer stability words.","Prefer version constraints (@dev, @beta) over --stability when unsure."],"tags":["create-project","validation","stability"],"backgroundTag":null,"analyzedSha":"c435d285c9120efdca35696769c72ea9fdcc0466","analyzedAt":"2026-08-07T18:58:23.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}