siyuan-note/siyuan · error
duplicate inherited variable
Error message
duplicate inherited variable %q
What it means
validateMCPServerEnvironment rejects a server whose InheritEnv list contains the same variable name more than once. On Windows comparison is case-insensitive (environmentKey uppercases the name), so 'Path' and 'PATH' also count as duplicates. Inheriting the same variable twice is meaningless and likely a config mistake, so it fails fast.
Solutions
- Open the MCP server settings and remove the duplicated entry from the inherit-environment list
- Check for case-only duplicates when on Windows (Path vs PATH) and keep just one
- If the duplicate comes from a synced/imported config, deduplicate the inheritEnv array in conf.json and reload
Example fix
// before
server.InheritEnv = []string{"HOME", "PATH", "PATH"}
// after
server.InheritEnv = []string{"HOME", "PATH"} Defensive patterns
Strategy: validation
Validate before calling
seen := map[string]bool{}
for _, n := range server.InheritEnv {
k := strings.ToUpper(n) // match Windows semantics
if seen[k] { return fmt.Errorf("duplicate inherit %q", n) }
seen[k] = true
} Prevention
- Deduplicate InheritEnv whenever config is merged or imported
- Use case-insensitive comparison on Windows when adding inherit entries
- Validate with ValidateMCPServerEnvironment before saving the server entry
When it happens
Trigger: conf.MCPServer.InheritEnv contains the same name (case-insensitively on Windows) twice when ValidateMCPServerEnvironment runs or a stdio server is started via buildStdioEnvironment.
Common situations: Adding the same inherit entry twice in the MCP settings UI; merging configs where both entries inherited PATH; on Windows, adding both 'Path' and 'PATH' from different sources.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- duplicate variable
- invalid name
- variable contains NUL
- attr must be a string or null (got %T)
- command is required for stdio server
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/edf7d8bd4922d957.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/mcp/client/mcp.go:554
func validateEnvironmentName(name string) error {
if name == "" {
return errors.New("name is empty")
}
if strings.ContainsAny(name, "=\x00") {
return fmt.Errorf("invalid name %q", name)
}
return nil
}
func validateMCPServerEnvironment(server conf.MCPServer, goos string) error {
inherited := map[string]bool{}
for _, name := range server.InheritEnv {
if err := validateEnvironmentName(name); err != nil {
return err
}
key := environmentKey(name, goos)
if inherited[key] {
return fmt.Errorf("duplicate inherited variable %q", name)
}
inherited[key] = true
}
explicit := map[string]bool{}
for name, value := range server.Env {
if err := validateEnvironmentName(name); err != nil {
return err
}
if strings.ContainsRune(value, '\x00') {
return fmt.Errorf("variable %q contains NUL", name)
}
key := environmentKey(name, goos)
if explicit[key] {
return fmt.Errorf("duplicate variable %q", name)
}
explicit[key] = true
}
return nilView on GitHub (pinned to 9f775e8a12)