28

I'm new using Mac and I'd like to upgrade the available cURL-7.43.0 to the last version cURL-7.47.1? I'm looking at some pages, but they say to avoid upgrading the originals on OSX. Any help please? Thanks

Frank
  • 1,311
  • 2
  • 13
  • 15
  • Despite using homebrew, i found the version never matched "which curl", no matter what I did with the $PATH variable. So now I just give the full path to curl which is the latest version and it works. – user420667 Jan 24 '17 at 05:47
  • As I understand it, you can't update the base curl version on macs which is why people suggest using Homebrew to install the latest version of curl. – troxwalt Mar 29 '19 at 15:38

2 Answers2

30

Take a look at installing homebrew, it's a package manager that allow you to install and update binaries without overwriting your original ones.

You need then to prepend your PATH with homebrew's (/usr/local/bin by default). If you don't when you run curl the system will fetch the default OSX one (/usr/bin/curl) which isn't updated.

Use which curl when you're done to check !

hippietrail
  • 15,848
  • 18
  • 99
  • 158
MrKiwi
  • 343
  • 3
  • 10
  • 2
    How exactly does one "prepend" the path? Could you expand on this? – MadPhysicist Oct 31 '16 at 20:17
  • 5
    When I do `which curl` I get `/usr/bin/curl` back. However, when I try `brew upgrade curl` it tells me that curl is not installed. – MadPhysicist Oct 31 '16 at 20:18
  • @MadPhysicist here you go !! http://stackoverflow.com/questions/10343834/how-to-modify-path-for-homebrew – MrKiwi Oct 31 '16 at 20:54
  • @MrKiwi When I place `/usr/local/bin` above `/usr/bin` in the `/etc/paths` and then run `which curl` I still get `/usr/bin/curl` back. It seems that the system is still pulling from the default location. What could be the cause of this? – MadPhysicist Nov 01 '16 at 01:18
  • @MadPhysicist could you dump your path ? `env | grep -E "^PATH="` – MrKiwi Nov 04 '16 at 10:45
  • PATH=/usr/local/sbin:/Users/selfishman/.rvm/gems/ruby-2.3.0/bin:/Users/selfishman/.rvm/gems/ruby-2.3.0@global/bin:/Users/selfishman/.rvm/rubies/ruby-2.3.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin:/Users/selfishman/.rvm/bin – MadPhysicist Nov 07 '16 at 17:08
  • 3
    Try `brew info curl` to show how curl is installed - normally it is "keg only", meaning it is not on the PATH environment variable, as that command explains. So you will need to put the cellar-based path to curl shown by that command on your PATH. – RichVel Sep 21 '17 at 11:01
24

I had this issue as well with OSx locating curl at /usr/bin. If you install curl with brew install curl and then do brew info curl it will tell you the following near the bottom of the post-op output:

If you need to have this software first in your PATH run:

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

After running that command to update ~/.bash_profile you need to source it by executing . ~/.bash_profile

Florian
  • 2,796
  • 1
  • 15
  • 25
Smitty
  • 1,765
  • 15
  • 22
  • This does not update the `libcurl` header files available for C –  Apr 19 '21 at 12:53
  • 1
    Exactly! and it's very annoying for Git! because Git can't access to certificate managed by KeyChain. – JYC Apr 20 '21 at 13:19
  • @RichardMcFriendOluwamuyiwa @JYC True. Included in the brew output is also this `For compilers to find curl you may need to set: export LDFLAGS="-L/usr/local/opt/curl/lib" export CPPFLAGS="-I/usr/local/opt/curl/include"` – MEMark Sep 26 '21 at 09:41