1

I am trying to build gRPC inside a docker image, but updating the submodules is failing when using git version 2.8. Specifically this Dockerfile:

FROM alpine:3.3
RUN apk update && apk add git
RUN git clone -b 'v1.17.1' --depth 1 https://github.com/grpc/grpc
RUN git --version
RUN cd grpc && git submodule update --init --depth 1

shows git version 2.8.6 and throws the following error

Cloning into '/grpc/third_party/abseil-cpp'...
error: no such remote ref cc4bed2d74f7c8717e31f9579214ab52a9c9c610

If I switch to alpine:3.8 I get git version 2.18.1 and the build is successful. Is this a bug in the earlier version of git? Is there a workaround?

Notes:

  • I'm specifying --depth 1 because I don't need the commit history.
  • I have some unrelated constraints which make it difficult to use a more recent version.
stewbasic
  • 831
  • 7
  • 21
  • At `.gitmodules` you should update latest commit id of your sub module at `master` branch. – Quynh Nguyen Jan 02 '19 at 03:32
  • This commit id `cc4bed2d74f7c8717e31f9579214ab52a9c9c610` couldn't for access from your main project. – Quynh Nguyen Jan 02 '19 at 03:33
  • @QuỳnhNguyễn if that is the problem, why does it work correctly with the newer version of git? btw [the commit id exists](https://github.com/abseil/abseil-cpp/commit/cc4bed2d74f7c8717e31f9579214ab52a9c9c610). – stewbasic Jan 02 '19 at 03:35
  • This may explain the problem: https://github.com/CocoaPods/cocoapods-downloader/issues/32#issuecomment-56974091 – stewbasic Jan 02 '19 at 04:14

1 Answers1

1

As you can see in "How to make shallow git submodules?", multiple evolution have been made since Git 2.8.

If available, try and use only one step:

git clone -b 'v1.17.1' --recurse-submodule --depth 1 https://github.com/grpc/grpc 
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250