Preflight Checklist
- [x] I have searched the issue tracker for an issue that matches the one I want to file, without success.
- [x] I am not looking for support or already pursued the available support channels without success.
- [x] I have checked the troubleshooting guide for my problem, without success.
Viper Version
1.19.0
Go Version
1.24
Config Source
Files
Format
YAML
Repl.it link
No response
Code reproducing the issue
viper.SetConfigName("agent")
viper.SetConfigType("yaml")
viper.AddConfigPath(".")
viper.AddConfigPath("/config/path")
if err := viper.ReadInConfig(); err != nil {
return err
}
Expected Behavior
viper can find my config file /config/path/agent.yaml
successfully
Actual Behavior
an error occurred:
While parsing config: yaml: control characters are not allowed
Steps To Reproduce
I have a command tool called agent
, and a config file /config/path/agent.yaml
1. use viper to load config file as code shown above
2. start it by running ./agent
3. an error occurred
Additional Information
My binary called agent
, and my config file called agent.yaml
, viper does not search the config file in the secondary path /config/path, instead, it treats the binary agent
as a config file and try to parse it
related to https://github.com/spf13/viper/issues/1988