1

I have a git repo with a submodule in it which I would like to deploy to heroku on an auto-deployed pipeline, but when the ng build --prod process is near completion I get the error

ERROR in : Couldn't resolve resource ./repo/style.css relative to /tmp/build_d3089108a84fd9e7fb117fed84b787b6/src/app/resume/resume.component.ts

because my submodule (which exists at /src/app/resume/repo) is referenced in the file resume.component.ts:

@Component({
  selector: 'app-resume',
  templateUrl: './repo/resume.html',
  styleUrls: ['./repo/style.css']
})

and although the github repo points to a specific commit for the submodule, the initial git clone does not clone the submodule alongside it.

My .gitmodules file is as follows:

[submodule "Resume"]
    path = src/app/resume/repo
    url = https://github.com/<my username>/Resume.git

Question:

Is there a way to force heroku-git to clone submodules at the same time as the full repo?

Can I run a script that makes heroku clone the submodule on its own after cloning the full repo but before building?

Community
  • 1
  • 1
Lucas Burns
  • 393
  • 1
  • 3
  • 14
  • It [should just work](https://devcenter.heroku.com/articles/git-submodules#git-submodules). Are you sure you have a proper `.gitmodules` file? (Submodules aren't just nested repos; the [containing repo should have a `.gitmodules` file](https://git-scm.com/book/en/v2/Git-Tools-Submodules#_starting_submodules).) – ChrisGPT was on strike May 01 '19 at 00:24
  • I have a .gitmodules file set up, I'll add it to the post. And the repo is public – Lucas Burns May 01 '19 at 00:42
  • Are there any filename casing differences, e.g. `resume` vs. `Resume`? This would work on Windows and maybe macOS, but not on Heroku. – ChrisGPT was on strike May 01 '19 at 01:21
  • The first letter of the repo name is capitalized and everything else is lowercase. – Lucas Burns May 01 '19 at 01:24
  • 1
    Try `clone` with the recurse-submodules or recursive option (I forget which) – D. Ben Knoble May 01 '19 at 01:29
  • On my local machine this fixes it, but if I want heroku to pull submodules I have to use the answer from @VonC below – Lucas Burns May 01 '19 at 16:53

1 Answers1

2

The only issue with using GitHub repo submodules on Heroku would be:

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Yep, that custom buildpack trick fixed it. Setting https://github.com/dmathieu/heroku-buildpack-submodules as the first buildpack forced heroku to pull the complete submodule and the build succeeded – Lucas Burns May 01 '19 at 16:52