mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-15 20:44:01 +02:00
Avoid failing with "module not found" for hugo mod init and similar
Fixes #8940
This commit is contained in:
@@ -309,7 +309,12 @@ func (c *commandeer) loadConfig(mustHaveConfigFile, running bool) error {
|
||||
doWithConfig)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
// We should improve the error handling here,
|
||||
// but with hugo mod init and similar there is a chicken and egg situation
|
||||
// with modules already configured in config.toml, so ignore those errors.
|
||||
if mustHaveConfigFile || !moduleNotFoundRe.MatchString(err.Error()) {
|
||||
return err
|
||||
}
|
||||
} else if mustHaveConfigFile && len(configFiles) == 0 {
|
||||
return hugolib.ErrNoConfigFile
|
||||
}
|
||||
|
Reference in New Issue
Block a user