[racket-dev] Using `git submodule` vs. `git pull --ff-only upstream master`

From: Greg Hendershott (greghendershott at gmail.com)
Date: Thu Apr 17 21:25:41 EDT 2014

For whoever else might find this useful building on OS X.

Building HEAD today I got this new error:

raco setup: --- creating launchers ---
raco setup: launcher: <console-bin>/raco
raco setup: --- installing man pages ---
raco setup: --- installing collections ---
raco setup: --- post-installing collections ---
raco setup: --- checking package dependencies ---
make install-common-last
make fix-paths
if [ "" != "" ]; then \
          racket/racketcgc -G /Users/greg/src/plt/racket/build/config -u \
            "../../collects/setup/unixstyle-install.rkt" \
            make-install-destdir-fix "../.." \
"/Users/greg/src/plt/racket/racket/man" "yes"; \
make preserve-raco-pkg-default-scope
cp "../COPYING-libscheme.txt" "../COPYING_LESSER.txt" "../COPYING.txt"
if racket/bin/racket -G build/config -I racket/base -e '(case
(system-type) [(macosx) (exit 0)] [else (exit 1)])' ; then make
native-from-git ; fi
if [ ! -d native-pkgs/racket-win32-i386 ]; then make complain-no-submodule ; fi
make pkg-links PKGS="main-distribution plt-services" LINK_MODE="--save"
racket/bin/racket -U -G build/config racket/src/link-all.rkt ++dir
pkgs ++dir native-pkgs --save main-distribution plt-services
Linking packages:
Recording packages choice in racket/etc/link-pkgs.rktd
link-all: requested package not available: "draw-x86_64-macosx-2"
   /Users/greg/src/plt/racket/racket/src/link-all.rkt:150:6: for-loop
   /Users/greg/src/plt/racket/racket/src/link-all.rkt:148:2: loop
   /Users/greg/src/plt/racket/racket/src/link-all.rkt: [running body]
make[2]: *** [pkg-links] Error 1
make[1]: *** [plain-in-place] Error 2
make: *** [in-place] Error 2

Although this is unlike the previous symptoms of stale submodules,
"draw-x86_64-macosx-2" sounds like something that might be related to
native-pkgs. So on a hunch I tried this:

$ git submodule update
remote: Counting objects: 214, done.
remote: Compressing objects: 100% (157/157), done.
remote: Total 214 (delta 59), reused 183 (delta 44)
Receiving objects: 100% (214/214), 19.84 MiB | 54 KiB/s, done.
Resolving deltas: 100% (59/59), done.
>From https://github.com/plt/libs
   b698e73..3d8856e  master     -> origin/master
Submodule path 'native-pkgs': checked out

Although it was an unusually slow/big fetch, it succeeded.

And now the build now. (Well as I type this, my laptop fans are
blazing away, as it is still running the raco setup stage. But it
proceeded OK past the point it was failing before.)

Maybe this is obvious to everyone else, but I wanted to mention it in
case it helped anyone else building on OS X.

On Tue, Dec 17, 2013 at 4:48 PM, Greg Hendershott
<greghendershott at gmail.com> wrote:
> To answer my own question, back in July Matthew had posted here:
> On Sat, Jul 27, 2013 at 9:10 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
>> Nothing has been split out of the current git repository, but there is
>> now a "native-pkgs" git submodule for the native-library packages.
>> If you build on Mac OS X or Windows or if you run a snapshot build,
>> then you'll need to use
>>   git pull
>>   git submodule init
>>   git submodule update
>> once on each repository checkout from now on, and
>>   git pull
>>   git submodule update
>> for updates after the first checkout.
>> If you just `git pull' without the submodule commands, then you'll have
>> an empty "native-pkgs" directory. That's fine if you're building on,
>> say, Linux. If you're on Mac OS X or Windows, then the makefile should
>> give you a good error message and suggest using `git submodule init'
>> and `git submodule update'.
>> If you use `git submodule update' today and forget to use it in the
>> future, probably things will be fine for a long time, because
>> "native-pkgs" doesn't change often. If "native-pkgs" does change and
>> you forget `git submodule update', then (as I understand things) `git
>> status' will tell you that there's a mismatch. The mismatch report
>> might take a form that's not entirely clear, but it should be enough to
>> remind you to run `git submodule update'.
> It turned out that it wasn't enough to remind _me_. :)  Running `git
> submodule update` resolved this for me.
> On Fri, Sep 20, 2013 at 2:30 PM, Greg Hendershott
> <greghendershott at gmail.com> wrote:
>> I build Racket while keeping my forked repo's `master` branch an
>> exact, fast-forwardable copy of PLT's remote upstream `master`. [1]
>> This has worked fine building Racket on Linux, and continues to do so.
>> But on OS X, I need to follow these instructions from INSTALL.TXT, wrt
>> the pkg re-org:
>> On Mac OS X and Windows, you'll need native-library packages in the
>> "native-pkgs" directory. In the git repostory, "native-pkgs" is a git
>> submodule, so you'll need
>>    git submodule init
>>    git submodule update
>> to get it set up.
>> <<<
>> After I do so, the resulting build works great.
>> However it introduces a change:
>> greg at mbp in ~/src/plt/racket on master*
>> $ git diff
>> diff --git a/native-pkgs b/native-pkgs
>> index f367c0c..f8c8984 160000
>> --- a/native-pkgs
>> +++ b/native-pkgs
>> @@ -1 +1 @@
>> -Subproject commit f367c0c4b05b91401d68b0180b416d616b31720d
>> +Subproject commit f8c8984ebe8a442d474558dced0eb824cbb24772
>> <<<
>> If I commit this, my master wouldn't be a FF copy anymore (AFIK). So I don't.
>> But as a result, if I switch to a topic branch without committing
>> (normally a no-no), it's a bit weird:
>> greg at mbp in ~/src/plt/racket on master*
>> $ git checkout imap-append-flags
>> warning: unable to rmdir native-pkgs: Directory not empty
>> Switched to branch 'imap-append-flags'
>> <<<
>> After switching back to master, everything seems OK:
>> greg at mbp in ~/src/plt/racket on imap-append-flags*
>> $ git checkout master
>> M native-pkgs
>> Switched to branch 'master'
>> Your branch is ahead of 'origin/master' by 771 commits.
>> <<<
>> Is this -- the warning about native-pkgs -- something I should just
>> learn to ignore and treat as the new normal?
>> [1]: http://www.greghendershott.com/2013/04/a-guide-for-infrequent-contributors-to-racket.html

Posted on the dev mailing list.