Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homebrew not finding newer git from $PATH #6274

Closed
5 tasks done
joseph-long opened this issue Jul 3, 2019 · 14 comments
Closed
5 tasks done

Homebrew not finding newer git from $PATH #6274

joseph-long opened this issue Jul 3, 2019 · 14 comments

Comments

@joseph-long
Copy link

  • are reporting a bug others will be able to reproduce and not asking a question. If you're not sure or want to ask a question do so on our Discourse: https://discourse.brew.sh
  • ran a brew command and reproduced the problem with multiple formulae? If it's a problem with a single, official formula (not cask) please file this issue at Homebrew/homebrew-core: https://github.com/Homebrew/homebrew-core/issues/new/choose. If it's a brew cask problem please file this issue at https://github.com/Homebrew/homebrew-cask/issues/new/choose. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap.
  • ran brew update and can still reproduce the problem?
  • ran brew doctor, fixed all issues and can still reproduce the problem?
  • ran brew config and brew doctor and included their output with your issue?

What you were trying to do (and why)

brew update a new install of LinuxBrew to /extra/josephlong/.linuxbrew.

What happened (include command output)

Despite the existence of a newer git on $PATH:

17:30:23 login2:~ josephlong$ git --version
git version 2.9.5
17:30:25 login2:~ josephlong$ which git
~/.local/bin/git

Homebrew appears to use system git, which is much older:

$ brew config
[...]
Git: 1.7.1 => /usr/bin/git
[...]

which results in the following errors:

Command output

$ brew update
==> Installing dependencies for curl: pkg-config and openssl
==> Installing curl dependency: pkg-config
error: unknown option `local'
usage: git config [options]

Config file location
--global use global config file
--system use system config file
-f, --file use given config file

Action
--get get value: name [value-regex]
--get-all get all values: key [value-regex]
--get-regexp get values for regexp: name-regex [value-regex]
--replace-all replace all matching variables: name value [value_regex]
--add adds a new variable: name value
--unset removes a variable: name [value-regex]
--unset-all removes all matches: name [value-regex]
--rename-section rename section: old-name new-name
--remove-section remove a section: name
-l, --list list all
-e, --edit opens an editor
--get-color find the color configured: [default]
--get-colorbool
find the color setting: [stdout-is-tty]

Type
--bool value is "true" or "false"
--int value is decimal number
--bool-or-int value is --bool or --int
--path value is a path (file or directory name)

Other
-z, --null terminate values with NUL byte

Error: Failure while executing; git config --local --replace-all homebrew.private false exited with 129.
==> Installing dependencies for git: patchelf, zlib, binutils, linux-headers, glibc, m4, gmp, mpfr, libmpc, isl@0.18, gcc, pkg-config, gpatch, ncurses, gettext, bzip2, pcre2, openssl, curl, libbsd and expat
==> Installing git dependency: patchelf
error: unknown option `local'
usage: git config [options]

Config file location
--global use global config file
--system use system config file
-f, --file use given config file

Action
--get get value: name [value-regex]
--get-all get all values: key [value-regex]
--get-regexp get values for regexp: name-regex [value-regex]
--replace-all replace all matching variables: name value [value_regex]
--add adds a new variable: name value
--unset removes a variable: name [value-regex]
--unset-all removes all matches: name [value-regex]
--rename-section rename section: old-name new-name
--remove-section remove a section: name
-l, --list list all
-e, --edit opens an editor
--get-color find the color configured: [default]
--get-colorbool
find the color setting: [stdout-is-tty]

Type
--bool value is "true" or "false"
--int value is decimal number
--bool-or-int value is --bool or --int
--path value is a path (file or directory name)

Other
-z, --null terminate values with NUL byte

Error: Failure while executing; git config --local --replace-all homebrew.private false exited with 129.
error: unknown option `list'
usage: git tag [-a|-s|-u ] [-f] [-m |-F ] []
or: git tag -d ...
or: git tag -l [-n[]] []
or: git tag -v ...

-l                    list tag names
-n[<n>]               print <n> lines of each tag message
-d                    delete tags
-v                    verify tags

Tag creation options
-a annotated tag, needs a message
-m message for the tag
-F message in a file
-s annotated and GPG-signed tag
-u use another key to sign the tag
-f, --force replace the tag if exists

Tag listing options
--contains print only tags that contain the commit

error: unknown option `list'
usage: git tag [-a|-s|-u ] [-f] [-m |-F ] []
or: git tag -d ...
or: git tag -l [-n[]] []
or: git tag -v ...

-l                    list tag names
-n[<n>]               print <n> lines of each tag message
-d                    delete tags
-v                    verify tags

Tag creation options
-a annotated tag, needs a message
-m message for the tag
-F message in a file
-s annotated and GPG-signed tag
-u use another key to sign the tag
-f, --force replace the tag if exists

Tag listing options
--contains print only tags that contain the commit

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.

Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics

error: unknown option `local'
usage: git config [options]

Config file location
--global use global config file
--system use system config file
-f, --file use given config file

Action
--get get value: name [value-regex]
--get-all get all values: key [value-regex]
--get-regexp get values for regexp: name-regex [value-regex]
--replace-all replace all matching variables: name value [value_regex]
--add adds a new variable: name value
--unset removes a variable: name [value-regex]
--unset-all removes all matches: name [value-regex]
--rename-section rename section: old-name new-name
--remove-section remove a section: name
-l, --list list all
-e, --edit opens an editor
--get-color find the color configured: [default]
--get-colorbool
find the color setting: [stdout-is-tty]

Type
--bool value is "true" or "false"
--int value is decimal number
--bool-or-int value is --bool or --int
--path value is a path (file or directory name)

Other
-z, --null terminate values with NUL byte

Error: Failure while executing; git config --local --replace-all homebrew.analyticsmessage true exited with 129.

What you expected to happen

I expected brew update to complete without errors.

Step-by-step reproduction instructions (by running brew commands)

$ cd /extra/$USER   # non-standard install prefix
$ git clone https://github.com/Homebrew/brew .linuxbrew/Homebrew
$ mkdir .linuxbrew/bin
$ ln -s ../Homebrew/bin/brew .linuxbrew/bin
$ eval $(/extra/josephlong/.linuxbrew/bin/brew shellenv)
$ brew update

brew doctor

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: An outdated version (1.7.1) of Git was detected in your PATH.
Git 2.7.0 or newer is required for Homebrew.
Please upgrade:
  brew install git

Warning: Your Homebrew's prefix is not /home/linuxbrew/.linuxbrew.
Some of Homebrew's bottles (binary packages) can only be used with the default
prefix (/home/linuxbrew/.linuxbrew).
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Discourse, Twitter or IRC. You are responsible for resolving any issues you
experience, as you are running this unsupported configuration.

brew config

HOMEBREW_VERSION: >=1.7.1 (shallow or no git repository)
ORIGIN: https://github.com/Homebrew/brew
HEAD: 6418230f8fc86093f96f4156a2cdcabfd55f03f7
Last commit: 2 days ago
Core tap ORIGIN: https://github.com/Homebrew/linuxbrew-core
Core tap HEAD: 42e132d75e8ee9ddf01e975ba28dbb0f3f791686
Core tap last commit: 3 hours ago
HOMEBREW_PREFIX: /extra/josephlong/.linuxbrew
HOMEBREW_CELLAR: /extra/josephlong/.linuxbrew/Cellar
HOMEBREW_CACHE: /home/u32/josephlong/.cache/Homebrew
HOMEBREW_LOGS: /home/u32/josephlong/.cache/Homebrew/Logs
HOMEBREW_REPOSITORY: /extra/josephlong/.linuxbrew/Homebrew
HOMEBREW_NO_ANALYTICS_THIS_RUN: 1
HOMEBREW_SYSTEM_CURL_TOO_OLD: 1
HOMEBREW_VISUAL: nano
CPU: 28-core 64-bit haswell
Homebrew Ruby: 2.3.7 => /extra/josephlong/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/bin/ruby
Clang: 3.4 build 34
Git: 1.7.1 => /usr/bin/git
Curl: 7.19.7 => /usr/bin/curl
Kernel: Linux 2.6.32-754.12.1.el6.x86_64 x86_64 GNU/Linux
OS: CentOS release 6.10 (Final) (Final)
Host glibc: 2.12
/usr/bin/gcc: 4.4.7
glibc: N/A
gcc: N/A
xorg: N/A
@sjackman
Copy link
Member

sjackman commented Jul 3, 2019

Unfortunately, I use Linuxbrew to try and save myself from the outdated software on my University's HPC cluster... they won't let me upgrade them to a newer CentOS 🙃

I created Linuxbrew for this reason, so you're in good company.

@sjackman
Copy link
Member

sjackman commented Jul 3, 2019

Try these (untested) alternative alternative (alternative²) installation instructions using curl rather than git to install Homebrew:

mkdir -p /home/linuxbrew/.linuxbrew/bin
curl -L https://github.com/Homebrew/brew/archive/2.1.6.tar.gz | tar zx -C /home/linuxbrew/.linuxbrew/Homebrew
ln -s ../Homebrew/bin/brew /home/linuxbrew/.linuxbrew/bin
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)

@sjackman
Copy link
Member

sjackman commented Jul 3, 2019

A couple of options to try to use your local ~/.local/bin/git executable. First, try export HOMEBREW_NO_ENV_FILTERING=1 to use your PATH rather than the default /usr/bin:/bin.
Second, you can export HOMEBREW_DEVELOPER=1 HOMEBREW_GIT_PATH=$HOME/.local/bin/git.

@sjackman
Copy link
Member

sjackman commented Jul 3, 2019

elif [[ -n "$HOMEBREW_DEVELOPER" && -x "$HOMEBREW_GIT_PATH" ]]
then
HOMEBREW_GIT="$HOMEBREW_GIT_PATH"
else

@sjackman
Copy link
Member

sjackman commented Jul 3, 2019

Once you get it working, I'd be most happy to review a PR that makes the installation smoother on older distributions. Here's a wiki with installation instructions on for CentOS 6. Feel free to edit it: https://github.com/Linuxbrew/brew/wiki/CentOS6

@joseph-long
Copy link
Author

export HOMEBREW_NO_ENV_FILTERING=1 might have done the trick! I'm certainly getting further along with brew update.

@joseph-long
Copy link
Author

I tried the curl instructions just to see if they worked (since that would be easier to document than building one's own git), but unfortunately brew update starts by converting the checkout to a shallow clone. I tried brew install git but it just installs portable ruby and then it too tries to convert the checkout to a git repo.

@joseph-long
Copy link
Author

Written up at https://joseph-long.com/writing/linuxbrew-with-ancient-git/ for posterity, as the wiki page you linked is archived. If there's another good place to put it, I can copy it over!

@sjackman
Copy link
Member

sjackman commented Jul 3, 2019

Nice write up! I've tweeted your article here: https://twitter.com/linuxbrew/status/1146457021174054918
Are you on Twitter? I couldn't find your handle. Get thee on Twitter! If only so other Science tweeps can tag you in posts.

Cutting edge research, eight year old operating systems. Go figure.

😂 This issue still mystifies me. Dealing with a ten year old operating system consumes so much time. It's absolutely insane. Docker and Singularity should help a lot. My site won't use Docker because of security concerns, but they're excited about Singularity.

@sjackman
Copy link
Member

sjackman commented Jul 3, 2019

an enterprising graduate student

That's me! Also, I graduated last month! I have a photo of me wearing a silly hat to prove it. 🎓 Would you mind linking to my web site? https://sjackman.ca

@sjackman
Copy link
Member

sjackman commented Jul 3, 2019

the wiki page you linked is archived

Hmm. Yes, I forgot about that. Do you have the time and inclination to submit a PR to improve the installation of Homebrew on older distributions? This would largely amount to detecting when git is too old, and either failing with a (hopefully helpful) error message, or better, taking an alternative installation route by default. If so, I'm happy to point you to the right section of code to get started hacking.

@MikeMcQuaid
Copy link
Member

If so, I'm happy to point you to the right section of code to get started hacking.

Here's some of the relevant code:

# The system Curl is too old for some modern HTTPS certificates on
# older macOS versions.
#
if [[ "$HOMEBREW_MACOS_VERSION_NUMERIC" -lt "101000" ]]
then
HOMEBREW_SYSTEM_CURL_TOO_OLD="1"
HOMEBREW_FORCE_BREWED_CURL="1"
fi
# The system Git on macOS versions before Sierra is too old for some Homebrew functionality we rely on.
HOMEBREW_MINIMUM_GIT_VERSION="2.14.3"
if [[ "$HOMEBREW_MACOS_VERSION_NUMERIC" -lt "101200" ]]
then
HOMEBREW_FORCE_BREWED_GIT="1"
fi

# Ensure the system Curl is a version that supports modern HTTPS certificates.
HOMEBREW_MINIMUM_CURL_VERSION="7.41.0"
system_curl_version_output="$($(command -v curl) --version 2>/dev/null)"
system_curl_name_and_version="${system_curl_version_output%% (*}"
if [[ $(numeric "${system_curl_name_and_version##* }") -lt $(numeric "$HOMEBREW_MINIMUM_CURL_VERSION") ]]
then
HOMEBREW_SYSTEM_CURL_TOO_OLD="1"
HOMEBREW_FORCE_BREWED_CURL="1"
fi

# Ensure the system Git is at or newer than the minimum required version.
# Git 2.7.4 is the version of git on Ubuntu 16.04 LTS (Xenial Xerus).
HOMEBREW_MINIMUM_GIT_VERSION="2.7.0"
system_git_version_output="$($(command -v git) --version 2>/dev/null)"
if [[ $(numeric "${system_git_version_output##* }") -lt $(numeric "$HOMEBREW_MINIMUM_GIT_VERSION") ]]
then
HOMEBREW_FORCE_BREWED_GIT="1"
fi

It seems some of this should be happening already.

@joseph-long
Copy link
Author

In the command output above, you can see brew following the "force brewed git" (and curl) path, but other parts of Homebrew are supplying arguments to git that are too new, and the attempt to install its own git fails.

I'm not sure if I should go through and make those invocations of git backwards compatible all the way back to 1.7.1... ideally there'd be a "portable git" like the portable ruby homebrew installs, but that may be more effort than it's worth for such an old system.

@sjackman
Copy link
Member

sjackman commented Jul 4, 2019

It's only really brew update and some git config stuff that requires git. Much of that can be deferred until we have a working version of brewed git installed. The fix as I see it would be to detect when the system version of git is missing or too old (when HOMEBREW_FORCE_BREWED_CURL is set), and if the brewed git is not yet installed, skip running git. For example, don't auto-update until the brewed git is installed. Does that make sense?

@Homebrew Homebrew deleted a comment from taralx Dec 15, 2019
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Dec 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants