netbirdio/netbird · error
create service config: %w
Error message
create service config: %w
What it means
Thrown while building the system service definition for `netbird service install`. createServiceConfigForInstall calls newSVCConfig, which in practice only fails when the extra service environment variables cannot be parsed, so this wrap almost always carries a parseServiceEnvVars failure underneath.
Source
Thrown at client/cmd/service_installer.go:119
}
}
if runtime.GOOS == "windows" {
svcConfig.Option["OnFailure"] = "restart"
}
return nil
}
// Create fully configured service config for install/reconfigure
func createServiceConfigForInstall() (*service.Config, error) {
if err := validateJSONSocketFlags(); err != nil {
return nil, err
}
svcConfig, err := newSVCConfig()
if err != nil {
return nil, fmt.Errorf("create service config: %w", err)
}
svcConfig.Arguments = buildServiceArguments()
if err = configurePlatformSpecificSettings(svcConfig); err != nil {
return nil, fmt.Errorf("configure platform-specific settings: %w", err)
}
return svcConfig, nil
}
var installCmd = &cobra.Command{
Use: "install",
Short: "Install NetBird service",
RunE: func(cmd *cobra.Command, args []string) error {
if err := setupServiceCommand(cmd); err != nil {
return err
}
View on GitHub (pinned to 93e97f4bf1)
Solutions
- Rewrite each --service-env entry as KEY=VALUE, e.g. --service-env NB_LOG_LEVEL=debug,CUSTOM_VAR=value
- Quote the whole flag value in the shell so commas and '=' survive intact
- Remove stray entries like a trailing comma producing an empty element
- Re-run sudo netbird service install
Example fix
# before netbird service install --service-env NB_LOG_LEVEL # after netbird service install --service-env NB_LOG_LEVEL=debug
Defensive patterns
Strategy: validation
Validate before calling
func validEnvEntries(entries []string) error {
for _, e := range entries {
if e == "" {
continue
}
if k, _, ok := strings.Cut(e, "="); !ok || strings.TrimSpace(k) == "" {
return fmt.Errorf("bad entry %q: want KEY=VALUE", e)
}
}
return nil
}
if err := validEnvEntries(serviceEnvVars); err != nil {
return err
} Try / catch
if err := createServiceConfigForInstall(); err != nil {
return fmt.Errorf("create service config: %w", err)
}
// The chain contains 'parse service environment variables'; surface the offending entry to the user instead of retrying. Prevention
- Always write --service-env entries as KEY=VALUE
- Quote the whole flag value in the shell
- Validate env entries in scripts before invoking install
When it happens
Trigger: `netbird service install --service-env FOO` (entry without '='), `--service-env "=value"` (empty key), or a value containing a comma that StringSliceVar splits into a bogus second entry.
Common situations: Passing env vars shell-style (`--service-env NB_LOG_LEVEL debug`), forgetting quotes so the shell mangles the list, or values with commas splitting into entries that are not KEY=VALUE.
Related errors
- install service: %w
- check service status: %w
- remove service params: %w
- watcher closed unexpectedly
- %s: %w
AI-assisted analysis of netbirdio/netbird@93e97f4bf1 (2026-08-16).
Data as JSON: /api/errors/95c16af2efcab438.
Report an issue: GitHub.