shadcn-ui/ui · error
The provided cwd must match config.resolvedPaths.cwd.
Error message
The provided cwd must match config.resolvedPaths.cwd.
What it means
Plain Error thrown by addRegistryItems when both `cwd` (inputCwd) and the config's resolvedPaths.cwd are defined but resolve to different absolute paths. The API treats cwd and config.resolvedPaths.cwd as a single source of truth and refuses ambiguous input rather than guessing which one wins.
Source
Thrown at packages/shadcn/src/registry/add.ts:55
? inputConfig.resolvedPaths.cwd
: undefined
throw new ConfigParseError(
path.resolve(inputCwd ?? configCwd ?? process.cwd()),
parsedConfig.error,
"config"
)
}
const configCwd = parsedConfig.success
? parsedConfig.data.resolvedPaths.cwd
: undefined
const cwd = path.resolve(inputCwd ?? configCwd ?? process.cwd())
if (
inputCwd !== undefined &&
configCwd !== undefined &&
cwd !== path.resolve(configCwd)
) {
throw new Error("The provided cwd must match config.resolvedPaths.cwd.")
}
const config = configWithDefaults(
parsedConfig.success
? parsedConfig.data
: {
...inputConfig,
resolvedPaths: {
...inputConfig?.resolvedPaths,
cwd,
},
}
)
const env = await loadEnvFiles(cwd, {
processEnv: { ...process.env },
})
return withRegistryContext(View on GitHub (pinned to efac598707)
Solutions
- Pass only one of `cwd` or a config containing resolvedPaths.cwd — not both with conflicting values.
- If you need both, ensure they resolve identically: `path.resolve(cwd) === path.resolve(config.resolvedPaths.cwd)`.
- Resolve the Config from the same cwd you pass in, using get-config, before calling addRegistryItems.
Example fix
// before
addRegistryItems(['button'], {
cwd: '/projects/app',
config: { resolvedPaths: { cwd: '/projects/other-app' } }
})
// after — keep them consistent
const cwd = '/projects/app'
addRegistryItems(['button'], {
cwd,
config: { resolvedPaths: { cwd } }
}) Defensive patterns
Strategy: validation
Validate before calling
import path from 'path'
function assertCwdConsistent(inputCwd?: string, configCwd?: string) {
if (inputCwd !== undefined && configCwd !== undefined &&
path.resolve(inputCwd) !== path.resolve(configCwd)) {
throw new Error(`cwd (${inputCwd}) must equal config.resolvedPaths.cwd (${configCwd})`)
}
}
assertCwdConsistent(options.cwd, options.config?.resolvedPaths?.cwd) Prevention
- Pass only one of `cwd` or a config with resolvedPaths.cwd.
- When embedding, resolve Config from the same cwd each call.
- Avoid mixing programmatic cwd derivation with pre-resolved Config objects.
When it happens
Trigger: Calling addRegistryItems(['x'], { cwd: '/A', config: { resolvedPaths: { cwd: '/B' } } }); passing a cwd that differs in normalization (trailing slash, symlinks) from what the config embeds.
Common situations: Programmatic callers computing cwd from process.cwd() while passing a Config resolved earlier from a different directory; symlinked paths where path.resolve does not canonicalize to the same string.
Related errors
- INVALID_CONFIG
- A full project config is required to resolve target aliases.
- VALIDATION_ERROR
- MISSING_ENV_VARS
- "${registryName}" is a built-in registry and cannot be overr
AI-assisted analysis of shadcn-ui/ui@efac598707 (2026-08-12).
Data as JSON: /api/errors/ef385540697deeea.
Report an issue: GitHub.