Git submodule pull problem

I am having a problem updating git submodules during build phase. For some reason the build setup is using an older checkout, Manually updating a submodule via git submodule update --recursive --remote before building results it in a host key verification fail. The key is generated in deploy settings and added to gitlab ssh keys.

The site name is angry-easley-46326d

The build log file is

1:33:22 PM: Build ready to start

1:33:24 PM: build-image version: 6dfe19d15f524c85d6f9bf7df9fb30b0a9f0a61a

1:33:24 PM: build-image tag: v3.3.10

1:33:24 PM: buildbot version: 90cbc3789500c2dd7143d55a5b3bf1480401aa91

1:33:24 PM: Fetching cached dependencies

1:33:24 PM: Starting to download cache of 192.4MB

1:33:25 PM: Finished downloading cache in 1.027869974s

1:33:25 PM: Starting to extract cache

1:33:32 PM: Finished extracting cache in 6.887459177s

1:33:32 PM: Finished fetching cache in 7.958734118s

1:33:32 PM: Starting to prepare the repo for build

1:33:32 PM: Preparing Git Reference refs/heads/master

1:33:33 PM: Starting build script

1:33:33 PM: Installing dependencies

1:33:33 PM: Python version set to 3.7

1:33:34 PM: Started restoring cached node version

1:33:37 PM: Finished restoring cached node version

1:33:37 PM: v10.20.1 is already installed.

1:33:38 PM: Now using node v10.20.1 (npm v6.14.4)

1:33:38 PM: Attempting ruby version 2.6.2, read from environment

1:33:39 PM: Using ruby version 2.6.2

1:33:39 PM: Using PHP version 5.6

1:33:40 PM: 5.2 is already installed.

1:33:40 PM: Using Swift version 5.2

1:33:40 PM: Started restoring cached node modules

1:33:40 PM: Finished restoring cached node modules

1:33:40 PM: Started restoring cached yarn cache

1:33:40 PM: Finished restoring cached yarn cache

1:33:40 PM: Installing NPM modules using Yarn version 1.17.0

1:33:41 PM: yarn install v1.17.0

1:33:41 PM: warning package.json: No license field

1:33:41 PM: warning polulle@1.0.0: No license field

1:33:41 PM: [1/4] Resolving packages...

1:33:41 PM: [2/4] Fetching packages...

1:33:50 PM: info fsevents@1.2.12: The platform "linux" is incompatible with this module.

1:33:50 PM: info "fsevents@1.2.12" is an optional dependency and failed compatibility check. Excluding it from installation.

1:33:50 PM: [3/4] Linking dependencies...

1:33:54 PM: [4/4] Building fresh packages...

1:33:55 PM: success Saved lockfile.

1:33:55 PM: Done in 14.47s.

1:33:55 PM: NPM modules installed using Yarn

1:33:55 PM: warning package.json: No license field

1:33:55 PM: Started restoring cached go cache

1:33:55 PM: Finished restoring cached go cache

1:33:55 PM: go version go1.12 linux/amd64

1:33:55 PM: go version go1.12 linux/amd64

1:33:55 PM: Installing missing commands

1:33:55 PM: Verify run directory

1:33:55 PM: Executing user command: npm run build

1:33:56 PM: > polulle@1.0.0 build /opt/build/repo

1:33:56 PM: > npm run submodule; npm run static && parcel build src/frontend/index.html src/frontend/ src/frontend/index.en.html -d dist --no-source-maps

1:33:56 PM: > polulle@1.0.0 submodule /opt/build/repo

1:33:56 PM: > git submodule update --recursive --remote && cd src/shared && git log -n 2 && cd .. && cd ..

1:33:56 PM: Host key verification failed.

1:33:56 PM: fatal: Could not read from remote repository.

1:33:56 PM: Please make sure you have the correct access rights

1:33:56 PM: and the repository exists.

1:33:56 PM: Unable to fetch in submodule path 'src/shared'

1:33:56 PM: npm

1:33:56 PM: ERR!

1:33:56 PM: code ELIFECYCLE

1:33:56 PM: npm

1:33:56 PM: ERR! errno 1

1:33:56 PM: npm

1:33:56 PM: ERR! polulle@1.0.0 submodule: `git submodule update --recursive --remote && cd src/shared && git log -n 2 && cd .. && cd ..`

1:33:56 PM: npm

1:33:56 PM: ERR! Exit status 1

1:33:56 PM: npm

1:33:56 PM: ERR!

1:33:56 PM: npm ERR!

1:33:56 PM: Failed at the polulle@1.0.0 submodule script.

1:33:56 PM: npm

1:33:56 PM: ERR! This is probably not a problem with npm. There is likely additional logging output above.

1:33:56 PM: npm ERR! A complete log of this run can be found in:

1:33:56 PM: npm

1:33:56 PM: ERR! /opt/buildhome/.npm/_logs/2020-05-20T10_33_56_732Z-debug.log

1:33:57 PM: > polulle@1.0.0 static /opt/build/repo
1 Like

Hey @r0x0r,
We’ve seen a few of these git submodule things recently. Was this working for you before and it broke, or were you trying to get it working for the first time?

It worked once for me as in pulling the submodule for the first time after the initial configuration. After that it has failed to update the submodules.
I have tried to set up a manual pull (via setting ssh agent and configuring ssh keys), but eventually gave up and got rid of submodules for now. Hopefully this will get resolved soon.

Hey @r0x0r,
Thanks for your patience on this. I’m not sure how you’re loading your submodule or whether it’s public, but if it is public, I believe this is the fix:

In case your submodule is public , you can change the URI schema for it to start with https:// and it will should work without further adjustment (so, in .gitmodules , change… to… )

If it’s private, things get a bit more complicated. We have an in-depth support guide with some suggestions:

Can you take a look and let us know if any of these fix things for you?

It is a private repo.
Netlify is able to access the submodule repo, but fails to do subsequent updates. Git head fro the submodule is stuck at the first pull.
I am building from Gitlab, generated SSH keys should be good for all the projects.

1 Like

Hi @r0x0r. It looks like the submodule clone happens later in the build process and I don’t believe the build system will still have access to the deploy keys at that point. The submodule needs to be a Git submodule of the original repo to have our build system automatically clone the submodule.

Would you please confirm if the other repo is a Git submodule of the site’s repo or not?

I am having the same / similar issue.
I am new to Netlify and Hugo.
Originally, i had the whole Hugo Themes library in a separate folder and I would copy/paste from there into my repo. But I just started the git submodules that is recommended.
My hugo blog repo is private and hosted on Gitlab and uses an SSH key. That works fine and has.
When i add a git submodule, which is a public https (not ssh or git extension) and hosted on github as many of them are, i am getting a build error that it can’t be found.
This works locally when i run hugo.
I am seeing the folder in my repo on my gitlab, and it links to the github repo.
but the error message in the netlify build is that it can’t find that folder and it will fail shortly after that.

hey @KeithETruesdell, sorry to be slow to get back to you.

has there been any development on this issue? are you still experiencing the same?

Hi, @KeithETruesdell, there is also this support guide about submodules here:

Have you tried those instructions? If so, would you please send is the site name (aka subdomain) or the site API id (the id not the key)? Either (subdomain or id) will allow us to find the site in question and take a closer look.

Hi, @r0x0r, it is a private repository so I cannot see it myself. What does does the file .gitmodules contain? Would send us the contents of that file?

You can private message (PM) that to one of our support staff and I’ve confirmed that PMs are enabled for your community login. Note, that only one person can see the PM and this will likely mean a slower reply than posting the information publicly. Please feel free to reply to however you prefer though.

Hi, @r0x0r, from what I can see the submodule clone is working. I don’t see any errors in the logs about the clone failing:

The error for that deploy is:

4:42:21 AM: 🚨  /opt/build/repo/src/frontend/index.js:23:32: Cannot resolve dependency '../shared/util/localization/polulle' at '/opt/build/repo/src/shared/util/localization/polulle'
4:42:21 AM:   21 | import {txt, loadLocalization, selectedLanguage, setupLanguage, getUrlPrefix} from '../shared/util/localization'
4:42:21 AM:   22 | import globalLocalization from '../shared/util/localization/global'
4:42:21 AM: > 23 | import polulleLocalization from '../shared/util/localization/polulle'
4:42:21 AM:      |                                ^
4:42:21 AM:   24 | 
4:42:21 AM:   25 | 
4:42:21 AM:   26 | //import '@shared/util/swipe'

I’m not sure what is happening there as the repo is private so I cannot test this myself. It could be case sensitivity issues. Is you local developer system using MacOS? If so, the default filesystem is case-insensitive while the build system is Linux and is using a case-sensitive filesystem.

Could that explain the issue?

Hello @luke, @perry and others

Sorry for the delay on all this.
I was able to resolve this, and I forget where I saw something about this. I was having another issue with the Git repo locally as well, and I had to look into it in a different way. I am sorry I don’t have a reference, but hopefully this will help someone.

At the core, for me, this is not a netlify issue, or an issue with Hugo or the theme. This was something in the Git config.

.git --> config
If you go to the .git folder and open the config file, I found that there was some references to the Theme that i was trying to create a submodule. I had to go in, remove these reference, and there was some submodule references as well in there.
This was the root cause of my issue.
I would recommend anyone else to also check out this file, and see what is in it. If you don’t feel comfortable, don’t edit it (at least don’t save the edits…possibly even make a backup of the file…and worst case scenario, do a new git clone of the repo and start again).
Once I removed this, everything worked smoothly and fine.
I was not able to find the specific settings via a GUI like TortoiseGit or GitExtensions. I am not entirely sure how those “settings” got there or what they were in reference to (as I also can’t remember exactly what the config lines were for). So that is on me. Essentially, from memory, the lines were trying to reference folder or theme that had previously existed, that was not removed properly, and subsequent attempts to add or remove that did not affect the original “bad” one. Which was also on me and probably some goof I made trying to get a submodule theme or something.
I think as a horrible idea i had that I did once was I git clone or submodule the entire hugo themes git repo, making a bad reference for each of them. Brilliant on me.

So, thank you everyone for your help and guidance and patience. For anyone else, try to open that file and if you aren’t sure, post the contents of that file (possibly without the puttyfile and url lines). That might help in general.

Oh, one more thing, just as an FYI.
I still have the same configuration and setup for the repo really.

I have my netlify hugo repo with an ssh key / setup as private obviously, which is on GitLab. I have a submodule i am referencing that is on GitHub that is a public repository and no SSH key.

The issue wasn’t GitLab vs GitHub either, and I don’t think anyone thinks that, but I just want to make that clear in case someone thought that.

If anything, the case could have been public vs private repos and such.
However, that does not seem to be the case, though I appreciate the information from everyone as well.

Thank you all again.

Hi, @KeithETruesdell. Thank you so much for the follow-up to let us know what the solution was.

This is incredibly helpful for others searching the community site for answers and our support team appreciates it as well. :+1:

1 Like

My issue had to do with the misconfigured submodule as well (ie. the submodule configuration in .git/config did not match .gitmodules). Thanks everyone for support!