Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
40.3k stars 9.45k forks source link

Cannot make brew find appropriate git & curl without using unsupported variables #10776

Closed jacktose closed 3 years ago

jacktose commented 3 years ago

brew config output

$ HOMEBREW_DEVELOPER= HOMEBREW_NO_ENV_FILTERING= HOMEBREW_GIT_PATH= HOMEBREW_CURL_PATH= brew config
Error: Please update your system curl.
Minimum required version: 7.41.0
Your curl version: 7.29.0
Your curl executable: /usr/bin/curl
Error: Please update your system Git.
Minimum required version: 2.7.0
Your Git version: 1.8.3.1
Your Git executable: /usr/bin/git
HOMEBREW_VERSION: >=2.5.0 (shallow or no git repository)
ORIGIN: https://github.com/Homebrew/brew
HEAD: 9d62a13a316af2a4109ebd397cb24580364a5208
Last commit: 6 hours ago
Core tap ORIGIN: https://github.com/Homebrew/linuxbrew-core
Core tap HEAD: 190efc40f118bf2df48fea87a4e909b6df3ba337
Core tap last commit: 6 hours ago
Core tap branch: master
HOMEBREW_PREFIX: /data/shared/lusers/jacktose/.linuxbrew
HOMEBREW_REPOSITORY: /data/shared/lusers/jacktose/.linuxbrew/Homebrew
HOMEBREW_CELLAR: /data/shared/lusers/jacktose/.linuxbrew/Cellar
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: vim
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_MAKE_JOBS: 2
Homebrew Ruby: 2.6.3 => /data/shared/lusers/jacktose/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3_2/bin/ruby
CPU: dual-core 64-bit ivybridge
Clang: N/A
Git: 1.8.3.1 => /bin/git
Curl: 7.29.0 => /usr/bin/curl
Kernel: Linux 3.10.0-862.6.3.el7.x86_64 x86_64 GNU/Linux
OS: CentOS Linux release 7.9.2009 (Core) (Core)
Host glibc: 2.17
/usr/bin/gcc: 4.8.5
/usr/bin/ruby: N/A
glibc: 2.23
gcc@5: N/A
xorg: N/A

brew doctor output

Sorry about the mess. I don't control this system.

$ 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: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  isl@0.18

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
  /usr/lusers/enneking/bin/curl-config
  /usr/lusers/enneking/.linuxbrew/bin/pkg-config
  /usr/lusers/enneking/.linuxbrew/bin/ncurses6-config
  /usr/lusers/enneking/.linuxbrew/bin/ncursesw6-config
  /usr/lusers/enneking/.linuxbrew/bin/xml2-config
  /usr/lusers/enneking/.linuxbrew/bin/python3-config
  /usr/lusers/enneking/.linuxbrew/bin/python3.9-config
  /netops/local/bin/python3-config
  /netops/local/bin/php-config

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
  /usr/local/include/ezs.h
  ...
  /usr/local/include/node/zlib.h

Warning: Unbrewed '.la' files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected '.la' files:
  /usr/local/lib/libezs.la

Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected static libraries:
  /usr/local/lib/libezs.a

Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause formulae that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  gcc@5

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,
Twitter or any other official channels. You are responsible for resolving
any issues you experience while you are running this
unsupported configuration.

(full output)

What were you trying to do (and why)?

What

Use homebrew without unsupported options (HOMEBREW_DEVELOPER & HOMEBREW_NO_ENV_FILTERING), when appropriate versions of git and curl are not in homebrew's expected path.

Why

This system (for reasons unbeknownst to me) has ancient versions at /bin/git & /usr/bin/curl, below homebrew's minimum version of each. Recent versions are available at /usr/local/bin/git & ~/bin/curl, which are earlier in my PATH. You can see what I mean here. By default, homebrew uses PATH="/usr/bin:/bin:/usr/sbin:/sbin", so it finds the old versions and not the recent ones, and complains. Example here.

What happened (include all command output)?

When running most brew commands with default settings, brew warns about below-minimum versions of git and curl. (I will use brew config for examples, because it throws the errors but still completes, and shows some relevant info. Full examples in gist.)

ad-user-ads-11 ~ ★ HOMEBREW_DEVELOPER= HOMEBREW_NO_ENV_FILTERING= HOMEBREW_GIT_PATH= HOMEBREW_CURL_PATH= brew config
Error: Please update your system curl.
Minimum required version: 7.41.0
Your curl version: 7.29.0
Your curl executable: /usr/bin/curl
Error: Please update your system Git.
Minimum required version: 2.7.0
Your Git version: 1.8.3.1
Your Git executable: /usr/bin/git
HOMEBREW_VERSION: >=2.5.0 (shallow or no git repository)
...
Git: 1.8.3.1 => /bin/git
Curl: 7.29.0 => /usr/bin/curl
...

(full output)

Some time ago, I set export HOMEBREW_NO_ENV_FILTERING=1, which stops brew from setting its own path. Instead it uses mine and finds the better git and curl.

ad-user-ads-11 ~ ★ HOMEBREW_DEVELOPER= HOMEBREW_NO_ENV_FILTERING=1 HOMEBREW_GIT_PATH= HOMEBREW_CURL_PATH= brew config
HOMEBREW_VERSION: 3.0.4-14-g9d62a13
...
Git: 2.20.1 => /usr/local/bin/git
Curl: 7.61.1 => /usr/lusers/jacktose/bin/curl
...

However, HOMEBREW_NO_ENV_FILTERING recently triggered an issue, and is undocumented, unsupported, and untested. That issue affected me, so per @Bo98's advice, I am looking for a way to run brew stably with unusual git and curl paths. I tried setting HOMEBREW_GIT_PATH=/usr/local/bin/git & HOMEBREW_CURL_PATH="$HOME/bin/curl" but they have no effect alone. They only apply (and solve my problem) when also setting HOMEBREW_DEVELOPER=1, which is also not recommended for stable operation.

What did you expect to happen?

Ideally for me, homebrew would use the git and curl found in my PATH. I understand why that's not supportable. Perhaps in the special case of below-minimum versions of git and curl, it could look for appropriate versions in the user PATH?

Next best, I'd like to export the _PATH variables and have homebrew respect them. I.e. this invocation would work for me: $ HOMEBREW_DEVELOPER= HOMEBREW_NO_ENV_FILTERING= HOMEBREW_GIT_PATH=/usr/local/bin/git HOMEBREW_CURL_PATH="$HOME/bin/curl" brew config Perhaps they don't need to be gated behind _DEVELOPER, because a user who sets them presumably has reasons?

Or any other method of coercing homebrew to use known-good git and curl in non-standard locations.

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

  1. Install recent (>= homebrew minimum) version of git and/or curl and ensure they come first in your PATH.
  2. Install homebrew.
  3. Install below-minimum version of git and/or curl such that they come first in homebrew's PATH ("/usr/bin:/bin:/usr/sbin:/sbin") (but not yours).
  4. Run brew commands.
  5. Run brew commands with combinations of the following environment variables either unset or set as follows:
    • HOMEBREW_DEVELOPER=1
    • HOMEBREW_NO_ENV_FILTERING=1
    • HOMEBREW_GIT_PATH=<recent version>
    • HOMEBREW_CURL_PATH=<recent version>
jacktose commented 3 years ago

I know this stretches the definition of “reproducible,” but I am posting an issue per suggestion (https://github.com/Homebrew/brew/issues/10762#issuecomment-789929888).

If this can be fixed by a (modest) PR, I'm happy to take a crack at it, if someone will point me in the right direction.

MikeMcQuaid commented 3 years ago

Thanks for the report @jacktose.

Or any other method of coercing homebrew to use known-good git and curl in non-standard locations.

Out of interest: do either HOMEBREW_FORCE_BREWED_CURL or HOMEBREW_FORCE_BREWED_GIT work how you'd want/expect?

jacktose commented 3 years ago

@MikeMcQuaid I assume not currently, because I don't have brewed curl or git installed.* I'm happy to try if it's informative.

* Two reasons: 1. Recentish curl is an installation requirement for brew itself—or is it for gcc/glibc?—anyway, I had to build my own curl on this system to get brew going in the first place.

  1. Brewed curl built from source (and by extension, brewed git) has a mountain of dependencies which 1. bloat my brew setup and 2. have some build failures, last I tried.

I think #1 also means HOMEBREW_FORCE_BREWED_CURL can't be the only solution, or how else could I bootstrap brew with an old system curl?

Bo98 commented 3 years ago

HOMEBREW_CURL_PATH and HOMEBREW_GIT_PATH seems like the way to go - I've seen it used a few times, for bootstrapping in particular. In fact, even when brewed curl and git are automatically used, warning messages are still printed encouraging people to update system git.

They could probably be ungated from HOMEBREW_DEVELOPER. I don't really any reason to try stop people from using it - it's certainly way better than HOMEBREW_NO_ENV_FILTERING.

jacktose commented 3 years ago

@Bo98 That's a modest PR, alright. Opened #10796 to consider it. ~(Still have to figure out how to do tests, style`, etc.)~

MikeMcQuaid commented 3 years ago

In fact, even when brewed curl and git are automatically used, warning messages are still printed encouraging people to update system git.

This should be fixed.

They could probably be ungated from HOMEBREW_DEVELOPER. I don't really any reason to try stop people from using it - it's certainly way better than HOMEBREW_NO_ENV_FILTERING.

It's better but the "I'm using a random Git/Curl and now my Homebrew is broken" is a thing. If we're going to enable (and document) this when I think it needs to check if the curl and git actually work, are new enough and fail early and hard if not.

BrewTestBot commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.