{"record":{"id":"3a8f6dc49b37ff68","repo":"composer/composer","slug":"invalid-value-for-bin-compat-value-expected","errorCode":null,"errorMessage":"Invalid value for 'bin-compat': {value}. Expected auto, full or proxy","messagePattern":"Invalid value for 'bin-compat': (.+?)\\. Expected auto, full or proxy","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Composer/Config.php","lineNumber":472,"sourceCode":"\n                return max(0, (int) $size);\n\n            // special cases below\n            case 'cache-files-ttl':\n                if (isset($this->config[$key])) {\n                    return max(0, (int) $this->config[$key]);\n                }\n\n                return $this->get('cache-ttl');\n\n            case 'home':\n                return rtrim($this->process(Platform::expandPath($this->config[$key]), $flags), '/\\\\');\n\n            case 'bin-compat':\n                $value = $this->getComposerEnv('COMPOSER_BIN_COMPAT') ?: $this->config[$key];\n\n                if (!in_array($value, ['auto', 'full', 'proxy', 'symlink'])) {\n                    throw new \\RuntimeException(\n                        \"Invalid value for 'bin-compat': {$value}. Expected auto, full or proxy\"\n                    );\n                }\n\n                if ($value === 'symlink') {\n                    trigger_error('config.bin-compat \"symlink\" is deprecated since Composer 2.2, use auto, full (for Windows compatibility) or proxy instead.', E_USER_DEPRECATED);\n                }\n\n                return $value;\n\n            case 'discard-changes':\n                $env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES');\n                if ($env !== false) {\n                    if (!in_array($env, ['stash', 'true', 'false', '1', '0'], true)) {\n                        throw new \\RuntimeException(\n                            \"Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash\"\n                        );\n                    }","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/composer/composer/blob/6ffc1177404d0c50119c22dde6564a380f4a82c9/src/Composer/Config.php#L454-L490","documentation":"Thrown by Config::get() (RuntimeException) for 'bin-compat' when the effective value (from COMPOSER_BIN_COMPAT env or config) is not one of the allowed set. The code at src/Composer/Config.php:471 actually accepts ['auto','full','proxy','symlink'] (symlink triggers a deprecation), but the error message text only mentions 'auto, full or proxy' — a known mismatch between message and accepted set. Any other string triggers the exception.","triggerScenarios":"Setting COMPOSER_BIN_COMPAT or config.bin-compat to an unrecognized value like 'windows', 'both', 'true', or an empty string.","commonSituations":"Confusing bin-compat with a boolean; using a value from outdated docs or a different tool; typo in 'proxy'/'full'; message itself misleading users who set 'symlink' (which works but is deprecated).","solutions":["Use one of the accepted values: 'auto' (default, symlinks on *nix), 'full' (compat copies for Windows), or 'proxy' (proxy wrappers).","'symlink' is also accepted but deprecated since Composer 2.2 — migrate to 'auto'.","Unset COMPOSER_BIN_COMPAT / remove the config key to fall back to the default 'auto'."],"exampleFix":"// before\n$ COMPOSER_BIN_COMPAT=windows composer install\n// throws: Invalid value for 'bin-compat': windows. Expected auto, full or proxy\n\n// after: use a supported value (or unset to default to auto)\n$ COMPOSER_BIN_COMPAT=full composer install\n// or in composer.json: {\"config\": {\"bin-compat\": \"full\"}}","handlingStrategy":"validation","validationCode":"// Validate bin-compat before setting it\n$allowed = ['auto', 'full', 'proxy', 'symlink'];\nif (!in_array($value, $allowed, true)) {\n    throw new \\InvalidArgumentException(\"bin-compat '$value' invalid; use one of: auto, full, proxy.\");\n}","typeGuard":"/** @param mixed $v */\nfunction isValidBinCompat($v): bool {\n    return in_array($v, ['auto', 'full', 'proxy', 'symlink'], true);\n}","tryCatchPattern":"try {\n    $config->get('bin-compat');\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), \"Invalid value for 'bin-compat'\")) {\n        // reset to default and warn (note: 'symlink' is accepted but deprecated)\n        $config->merge(['config' => ['bin-compat' => 'auto']]);\n        return 'auto';\n    }\n    throw $e;\n}","preventionTips":["Use only 'auto', 'full', or 'proxy' for bin-compat.","Migrate away from deprecated 'symlink'.","Unset COMPOSER_BIN_COMPAT to rely on the 'auto' default."],"tags":["config","validation","bin-compat","user-input"],"analyzedSha":"6ffc1177404d0c50119c22dde6564a380f4a82c9","analyzedAt":"2026-08-07T00:01:08.491Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}