"failed to load modules" error after hugo update

To start with, our problem seems very similar to the one mentioned at "module not found" and "module does not exist" error since >=0.112.0, but upgrading to version 112.3 or greater did not resolve the problem for us.

We have multiple environments, each with their own content modules, organized as below:

config/
├─ _default/
│  ├─ config.yaml
├─ config1/
│  ├─ config.yaml
│  ├─ module.yaml
├─ config2/
│  ├─ config.yaml
│  ├─ module.yaml
├─ config3/
│  ├─ config.yaml
│  ├─ module.yaml

Each module.yaml imports one or more modules from git repositories in our on-prem azure devops instance.

When serving the site locally for development we run the below commands to initialize and serve a given site:

hugo mod init <ourDevopsModulePath>
hugo mod clean
hugo mod tidy
hugo serve -e config1 (or whichever config we are using)

When using version 111.3 this works with no issues, initializing the module and correctly downloading dependencies and serving the site. When using more recent versions (the earliest we’ve tested is 112.2 but it continues to happen in the most recent 113 release), the initial hugo mod init command (and any hugo command run from this directory) immediately fails with the below error:

hugo mod init <ourDevopsModulePath>
Error: failed to load modules: module "<pathToOneOfOurImportedModules>" not found in "<localPathOfSite>/themes/<ourDevopsModulePath>"; either add it as a Hugo Module or store it in "<localPathOfSite>/themes".: module does not exist

The specific module it says can’t be found is ALWAYS the last one listed in the last config. For example in the sample above it would error on the last import from config3. If I remove the config3 directory it will error on the last import in config2. And again, these paths all exist and work correctly in earlier hugo versions.

We can work around this issue by manually generating the go.mod file and removing the hugo mod init step, after which the remaining steps will complete with no errors, but we’re trying to determine the cause of the error and whether it’s some issue with our specific config or a bug that needs to be addressed. We did try opening a bug report and were told to try here for config help.

In that bug report (#11072) you provided this example:

module:
  hugoVersion:
    extended: true
    min: 0.100.0
  imports:
    - path: <URI>.git
      disable: false
      mounts:
        - source: assets
          target: assets
        - source: layouts
          target: layouts

To which bep responded:

The above is never a valid module path.

Can you elaborate, perhaps with more specific examples?

All of our module.yaml files in the config directory look like the below, with of course variations on the specific modules being imported.

I’m not quite sure what the note about that not being a valid module path really means, as that is the only syntax that will work with imports from azure devops, at least based on our testing. Trying to remove the .git results in errors, regardless of which version we’re using.

The error implies that for some reason it’s trying to look for the below paths on the local filesystem instead of searching online for them, but in the earlier version specified it did know to search online. Not sure what specifically changed that it seems to think these are now local paths, but that was not the case in 111.

Hope that helps clarify some, please let me know if there’s any other information I can give that would help.

hugoVersion:
  extended: true
  min: 0.100.0
imports:
  - path: our.azuredevops.url.com/devOpsCollectionName/devOpsProjectName/_git/Module.git
    disable: false
    mounts:
      - source: assets
        target: assets
      - source: static/images/home/VectorNetwork.png
        target: static/images/home/VectorNetwork.png
      - source: layouts
        target: layouts
  - path: github.com/google/docsy
    disable: false
  - path: github.com/google/docsy/dependencies
    disable: false
  - path: our.azuredevops.url.com/devOpsCollectionName/devOpsProjectName/_git/Module1.git
    disable: false
    mounts:
      - source: content
        target: content/module1
      - source: data
        target: data
      - source: static
        target: static
  - path: our.azuredevops.url.com/devOpsCollectionName/devOpsProjectName/_git/Module2.git
    disable: false
    mounts:
      - source: content
        target: content/module2
      - source: data
        target: data
      - source: static
        target: static
  - path: our.azuredevops.url.com/devOpsCollectionName/devOpsProjectName/_git/Module3.git
    disable: false
    mounts:
      - source: content
        target: content/module3
      - source: data
        target: data
      - source: static
        target: static

Does your Git configuration match what Microsoft describes here?
https://learn.microsoft.com/en-us/azure/devops/repos/git/go-get?view=azure-devops#go-get-with-private-projects

Because, out of the box:

$ go get github.com/jmooring/hugo-content.git
go: github.com/jmooring/hugo-content.git: invalid version control suffix in github.com/ path

It doesn’t, those directions appear to be for Azure devops Services (the cloud based version), on-prem devops uses different url formats and those instructions wouldn’t work for on-prem. We didn’t have any need to specify any of those settings previously, but i’ll work through those settings with the on-prem URL format and see if that helps at all and report back.