42

I'm super new to coding (actually trying to teach myself some Python), but there's a thing bugging me that I cannot seem to find any info online about my particular case: When I run git on the terminal, there is:

The "git" command requires the command line developer tools. Would you like to install.."

Now, since I have a very basic Macbook 12, I try to keep it as lightweight and uncluttered as possible, so I don't want to install any IDE or anything, I'm practising coding with vim 7.3, but in order to install Vundle.vim to manage any plugins, I need git, is there a way I can install it without having to install Homebrew?

Thanks for any input! And sorry if I didn't express myself correctly. So basically to sum up:

– I need git to install Vundle.vim, (or is there any other way?).

– I run git on terminal and get an error that I need to install Xcode, which is like 7GB heavy.

– I don't want to install Xcode or Homebrew.

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
mariano-daniel
  • 539
  • 1
  • 4
  • 12
  • You could install VirtualBox and install what you need on a virtual machine. Then you don't have to worry about "cluttering" the Macbook. – tay10r Nov 28 '19 at 02:04
  • @tay10r: Thanks! But I'd rather keep my developing tools in my computer in case I don't have internet access. But thanks for the tip! – mariano-daniel Nov 28 '19 at 02:06
  • Searching online for "installing git on mac" brought [this result](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git#_installing_on_macos) which may be an option. – metatoaster Nov 28 '19 at 02:09
  • @metatoaster: D'oh! Thanks! I honestly looked so hardly for the answer, and it was right in front of me. I'll give this link a try and see if I can avoid the Gigabytes from installing Xcode. Thanks! – mariano-daniel Nov 28 '19 at 02:13
  • 1
    @iPodClassic what's internet access have to do with that? A virtual machine doesn't require internet access. – tay10r Nov 28 '19 at 02:21
  • Command line tools are relatively small (the original Unix ones fit in 64K of RAM and less than ten MB of disk storage). GUIs like Xcode tend to be fat and resource-hogs. – torek Nov 28 '19 at 02:21
  • 1
    @torek The most recent version of the Xcode command line tools is 220 MB. – AMC Nov 28 '19 at 02:32
  • OP, the **command line tools** can be installed on their own, I don’t understand why the entire Xcode IDE would be required. See, for example: http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/. – AMC Nov 28 '19 at 02:34

5 Answers5

217

For me problem has resolved with:

xcodebuild -runFirstLaunch
Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
markych
  • 2,271
  • 2
  • 2
  • 4
  • 8
    Thanks - I have no idea, what this piece of code does - but it solved the issue for me. – Ruby Nanthagopal Sep 15 '22 at 05:56
  • 1
    This one solved the problem! – jux_97 Sep 15 '22 at 12:03
  • 1
    this is magic! solved the issue for me as well. :v: – rahulrvp Sep 16 '22 at 10:42
  • 1
    Note this also solves rust/cargo, python, and probably other problems. Perhaps you could explain what this bit of magic actually does? – Carlos Sep 16 '22 at 18:54
  • 4
    @bozdoz seriously, is there some macOS bug a bunch of us are running into here? Come to think of it, I did accept some updates recently. I can't remember if the incessant alert started the same day, though. :thinking: – Kevin Worth Sep 16 '22 at 19:38
  • 7
    Perfect ! I downloaded and installed it atleast 3 times by following the prompt, but the error still kept coming. But this command finally did the trick for me !! – jay1648 Sep 20 '22 at 07:09
  • 3
    This is serious magic. I likewise kept getting prompts to download and install command line tools until I ran this command. You earned a +1 from me. – Robert Hyatt Sep 20 '22 at 23:05
  • 3
    To those that keep getting this prompt in September / October 2022, even after numerous installs, the command above does solve that issue. – perte Oct 05 '22 at 09:55
  • 1
    @bozdoz what's funny is it probably deserved its own question because what many of us are experiencing currently appears to be a new bug and actually unrelated to the OP's question. Oh well... – Kevin Worth Oct 05 '22 at 16:54
  • 2
    Solves 'git requires developer tools...' error after updating to Monterey 12.6. thanks! – Taher Oct 09 '22 at 18:43
  • 1
    Thanks a lot, I don't know how many times I had downloaded from that prompt. This command worked like a magic! – Sagar Vaghela Oct 22 '22 at 04:49
  • This also works for issues with Homebrew/Mac Ports giving the same message. – Jonathan E. Landrum Oct 29 '22 at 13:59
17

For me it seemed like

xcodebuild -runFirstLaunch

solved the problem, but instead when I tried to use git, it still complained that it cannot find git and requested the installation of the XCode Developer Command Line Tools again and again. Until I found this answer here.

Long story short:

sudo xcode-select -switch /Library/Developer/CommandLineTools

saved my day.

NiklasLehnfeld
  • 984
  • 6
  • 14
12

There are three main sources for Git on macOS.

The first is Apple, using the command line developer tools. These tools install a standard set of Unix development tools, including a compiler and Git. While this is called the XCode development tools, it is significantly smaller than the full IDE XCode environment.

The second is Homebrew, which is commonly used for this purpose. It's going to be the most up to date. This also requires the command line developer tools.

The third is the download page from the Git website. This is maintained by a third party, not the Git maintainers, and isn't always up to date, but it's usually only a few versions behind.

The last option is to compile from source, but that requires a compiler, which generally requires the command line developer tools.

Barring other package managers like Fink, there are no other reputable sources for Git packages on macOS. You'll have to pick one of the options above if you want to use Git.

bk2204
  • 64,793
  • 6
  • 84
  • 100
  • 2
    I want to mention `nix` as a fourth source, but the macOS support is going through some issues with the release of Catalina at the moment. – chepner Dec 02 '19 at 16:23
  • Except Homebrew explicitly requires `git` as a prerequisite for installation. An error message in their installation script: `You must install Git before installing Homebrew` – Indigenuity May 27 '21 at 15:42
  • Right. If you want to use Homebrew, then you'll need the command line developer tools (or the full XCode), which will provide Git. You can then use Homebrew's version, which is generally more up to date. – bk2204 May 27 '21 at 23:11
4

I also happened to see this issue. And I tried to install the command line developer tools as the popup reminder. However, after the installed done, I restarted my MAC tens of times, also not work. [Repeated many times]

Finally, I tried to update the software with this cmd sudo softwareupdate -ia --verbose. It took more than half hour to download and another 20 mins to install and restart. The problem was solved to me. Hope this can help you.

Or try with this xcodebuild -runFirstLaunch

Jie Yin
  • 560
  • 5
  • 9
1

I encountered the same issue when I was going to use Git on a new macOS. My solution is pretty simple, but just to install homebrew.

The trick is that homebrew install loads a git repo of full source history. To achieve this, it firstly installs XCode command line development tool to get Git.

Then, after you have homebrew, you can benefit from XCode tools to issue git commands. Note that no need to install other parts of XCode here.

I was also surprised to see what happened at homebrew install. There might be a reason from homebrew developers.

themefield
  • 3,847
  • 30
  • 32