# Compile Error on Git 2.0.1 on Redhat 5.9 with Fix

4 messages from 2014-07-02 to 2014-07-03. Participants: Eldon Nelson, Matthieu Moy, Jeff King.
Thread: https://gitlist.dev/t/37043

## Eldon Nelson, 2014-07-02 15:56

Subject: Compile Error on Git 2.0.1 on Redhat 5.9 with Fix
Message-ID: <CAH5EwqY8D=CGxB+rZvwPH5115r9qmRCBBvJMG_o0962d4Uquxw@mail.gmail.com>
URL: https://gitlist.dev/e/CAH5EwqY8D%3DCGxB%2BrZvwPH5115r9qmRCBBvJMG_o0962d4Uquxw%40mail.gmail.com

```
When compiling Git 2.0.1 on RedHat 5.9 as a non-root user I get the
following error:

BUILD ERROR

ˋˋˋ
make prefix=/home/eldon/local all doc info
...
    CC zlib.o
    CC unix-socket.o
    CC thread-utils.o
    CC compat/strlcpy.o
    AR libgit.a
/bin/sh: gar: command not found
make: *** [libgit.a] Error 127
ˋˋˋ

My fix was to make a symlink below:

SYMLINK

ˋˋˋ
gar -> /usr/bin/ar
ˋˋˋ

LINUX VERSION

ˋˋˋ
> lsb_release -i -r
Distributor ID: RedHatEnterpriseClient
Release:        5.9
ˋˋˋ

I think the fix is to allow the use of "ar" if "gar" does not exist. I
don't know if this exists for every Redhat install but "gar" is not
available in /usr/bin but "ar" does.

ˋˋˋ
> /usr/bin/ar --version
GNU ar 2.17.50.0.6-20.el5_8.3 20061020
Copyright 2005 Free Software Foundation, Inc.
ˋˋˋ

It could just be my corporate install of RedHat that is weird, but
thought this might be at least a point to describe a fix.

ˋˋˋ
gcc --version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-54)
Copyright (C) 2006 Free Software Foundation, Inc.
ˋˋˋ

~~~~~~~~~~~~
Eldon Nelson
eldon_nelson@ieee.org
Cell: 952-393-3481

```

## Matthieu Moy, 2014-07-02 16:25

Subject: Re: Compile Error on Git 2.0.1 on Redhat 5.9 with Fix
Message-ID: <vpqtx6z4tih.fsf@anie.imag.fr>
URL: https://gitlist.dev/e/vpqtx6z4tih.fsf%40anie.imag.fr
In-Reply-To: <CAH5EwqY8D=CGxB+rZvwPH5115r9qmRCBBvJMG_o0962d4Uquxw@mail.gmail.com>

```
Eldon Nelson <eldon_nelson@ieee.org> writes:

> make prefix=/home/eldon/local all doc info
> ...
>     CC zlib.o
>     CC unix-socket.o
>     CC thread-utils.o
>     CC compat/strlcpy.o
>     AR libgit.a
> /bin/sh: gar: command not found
[...]
> I think the fix is to allow the use of "ar" if "gar" does not exist.

It is already the case. The Makefile defaults to "ar" and does not even
contain any mention of "gar". The configure script checks for both:

configure.ac:AC_CHECK_TOOLS(AR, [gar ar], :)

My guess is that you ran the configure script on a machine where gar is
present, and then used the result on a machine where it isn't.

Normally, at configure time you should see this:

checking for ar... ar

You actually don't need to run the configure script, the Makefile runs
fine without it. Delete config.mak.autogen to cancel the effect of
./configure.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Jeff King, 2014-07-02 16:29

Subject: Re: Compile Error on Git 2.0.1 on Redhat 5.9 with Fix
Message-ID: <20140702162947.GA14404@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20140702162947.GA14404%40sigill.intra.peff.net
In-Reply-To: <CAH5EwqY8D=CGxB+rZvwPH5115r9qmRCBBvJMG_o0962d4Uquxw@mail.gmail.com>

```
On Wed, Jul 02, 2014 at 10:56:25AM -0500, Eldon Nelson wrote:

> When compiling Git 2.0.1 on RedHat 5.9 as a non-root user I get the
> following error:
> 
> BUILD ERROR
> 
> ˋˋˋ
> make prefix=/home/eldon/local all doc info
> ...
>     CC zlib.o
>     CC unix-socket.o
>     CC thread-utils.o
>     CC compat/strlcpy.o
>     AR libgit.a
> /bin/sh: gar: command not found
> make: *** [libgit.a] Error 127
> ˋˋˋ

The Makefile defines AR as:

  $ git grep ^AR Makefile
  Makefile:AR = ar

so it should already do what you want by default.  But that make
variable can be overridden. Can you show us the contents of your
config.mak and config.mak.autogen files (if either exists)?

It's also possible that you have AR set in your environment (show us
"echo $AR"), but that would usually not override the Makefile unless
"make -e" is used (and that is not in your command-line above, but it's
possible that make is a shell alias or something).

> My fix was to make a symlink below:
> 
> SYMLINK
> 
> ˋˋˋ
> gar -> /usr/bin/ar
> ˋˋˋ

A simpler workaround is probably:

  make AR=ar ...

but probably the "right" solution is to eliminate whatever is providing
the bogus override in the first place.

-Peff

```

## Eldon Nelson, 2014-07-03 20:13

Subject: Re: Compile Error on Git 2.0.1 on Redhat 5.9 with Fix
Message-ID: <CAH5EwqbZygNg=Hiv_fTJ1wg5G07n_kUj77XK9eUmqh9+WPS3Dg@mail.gmail.com>
URL: https://gitlist.dev/e/CAH5EwqbZygNg%3DHiv_fTJ1wg5G07n_kUj77XK9eUmqh9%2BWPS3Dg%40mail.gmail.com
In-Reply-To: <CAH5EwqY8D=CGxB+rZvwPH5115r9qmRCBBvJMG_o0962d4Uquxw@mail.gmail.com>

```
Thanks for the tip Jeff.  "config.mak.autogen" is created in the git
compile only when you do a "./configure".  Mine had the bad reference
to "gar" in it due to the following.

It was caused because my path had a reference to a non-related "gar"
executable (some internal command).  I saw the compile trying to
execute it and removed it from my path.  Doing a "make clean"
afterwards didn't remove the "config.mak.autogen" which had mistakenly
thought that I was using "gar" and not "ar".

When I fixed my path to not include the company specific "gar" and
started with a fresh untar it worked perfectly.  It also didn't make a
"config.mak.autogen" since that isn't what is recommended to do in the
git docs for install.

This is closed due to my own user error.

config.mak.autogen

# git Makefile configuration, included in main Makefile
# config.mak.autogen.  Generated from config.mak.in by configure.

CC = cc
CFLAGS = -g -O2
CPPFLAGS =
LDFLAGS =
AR = gar
TAR = gtar

~~~~~~~~~~~~
Eldon Nelson
eldon_nelson@ieee.org

```
