summaryrefslogtreecommitdiffhomepage
path: root/commands
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2021-08-31 12:08:11 +0200
committerBjørn Erik Pedersen <[email protected]>2021-08-31 12:08:11 +0200
commita0489c2dfd3ceb4d0702de0da7a4af3eabce05e5 (patch)
tree4ad63fa9ab0b5ade625140682a11821e79a531a9 /commands
parent0fc2ce9e4bf0524994a861b7300e4332f6f8d390 (diff)
downloadhugo-a0489c2dfd3ceb4d0702de0da7a4af3eabce05e5.tar.gz
hugo-a0489c2dfd3ceb4d0702de0da7a4af3eabce05e5.zip
Avoid failing with "module not found" for hugo mod init and similar
Fixes #8940
Diffstat (limited to 'commands')
-rw-r--r--commands/commandeer.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/commands/commandeer.go b/commands/commandeer.go
index bac96fa7a..b2a995ae6 100644
--- a/commands/commandeer.go
+++ b/commands/commandeer.go
@@ -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
}