How to force Homebrew to use a newly installed version of curl?

Viewed 2025

I have recently installed a new version of Curl on my Mac using Homebrew (brew install curl). Now I want to make Homebrew itself use this new version. I've added the new curl location to my PATH (since Curl is keg-only) in my .profile.

So now my path shows as

PATH=/usr/local/opt/curl/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

And when I do which curl, I get what I expect:

/usr/local/opt/curl/bin/curl

And when I do curl -V I get the new version 7.77:

curl 7.77.0 (x86_64-apple-darwin17.7.0) libcurl/7.77.0 (SecureTransport) OpenSSL/1.1.1k zlib/1.2.11 brotli/1.0.9 zstd/1.5.0 libidn2/2.3.1 libssh2/1.9.0 nghttp2/1.43.0 librtmp/2.3 OpenLDAP/2.5.5
Release-Date: 2021-05-26
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL TLS-SRP UnixSockets zstd

which is different than what I get when I use the system Curl via /usr/bin/curl -V (version 7.54):

curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz HTTP2 UnixSockets HTTPS-proxy 

However, brew config reports

HOMEBREW_VERSION: 3.2.0
ORIGIN: https://github.com/Homebrew/brew
HEAD: 09f7bc27a99469cf947431df4754737dfbadb31d
Last commit: 15 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: cf1fa3d6052cca939b7efb5f6142fc56313cda51
Core tap last commit: 42 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 4
Homebrew Ruby: 2.6.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.3_2/bin/ruby
CPU: quad-core 64-bit westmere
Clang: 10.0.0 build 1000
Git: 2.17.2 => /Library/Developer/CommandLineTools/usr/bin/git

Curl: 7.54.0 => /usr/bin/curl     <---------- WHY?           

macOS: 10.13.6-x86_64
CLT: 10.1.0.0.1.1539992718
Xcode: N/A

And indeed, Brew appears to be using the older, system version of Curl, not the newly-install version, when downloading formulae.

My question: how to I get brew install <formula> to use the newer, freshly-installed, version of Curl? Or to put it another way, why is Brew continuing to use the older system Curl despite the changes to my PATH settings?

Thanks!

3 Answers

HOMEBREW_NO_ENV_FILTERING=1 brew update

You can export HOMEBREW_FORCE_BREWED_CURL=1, or put it in the ~/.bashrc

For Homebrew 3.6.2,

HOMEBREW_NO_ENV_FILTERING was deprecated for over a year and has now been removed (because it breaks many things)


When adding HOMEBREW_FORCE_BREWED_CURL=1 to brew config

> HOMEBREW_FORCE_BREWED_CURL=1 brew config

Curl: 7.85.0 => /usr/local/opt/curl/bin/curl

Now the curl could be referred to as the latest curl installed by brew.

However, both export HOMEBREW_FORCE_BREWED_CURL=1, or put it in the ~/.bashrc, the curl is still referred to /usr/bin/curl


Finally, we have to put curl in my PATH through

echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.zshrc

or .bash_profile

Now, the latest curl could be used directly in the terminal.

Related