Homebrew Xcode

Posted on  by 



My 2016 MacBook Pro has been sitting around ignored of late. My primary work laptop has been an Acer Predator for the last year. With the production release of Big Sur, I decided to upgrade the OS the day of release. This weekend, I tried to upgrade HomeBrew and everything it had installed, but quickly ran into a big issue with the Command Line Tools (CLT) being out of date.

Xcode

For those that are unfamiliar, Homebrew is “The Missing Package Manager for macOS”. Installing software that it supports is easy and it’s considered a must-have if you’re developing on macOS.

  • If you don’t have Apples Xcode Command Line Tools installed it will alert you to that it will install it and carry on with the Homebrew installation and download the Command Line Tools you will need to enter your admin password at some point. Then Homebrew is installed. After this Homebrew is installed and ready to install other apps.
  • Homebrew is a package manager designed for installing UNIX tools and other open-source applications on Mac OS X. It will quickly download and install them, compiling them from source. Homebrew Cask extends Homebrew with support for installing binary apps — the kind you normally drag to your Applications folder from DMG files.
  • Brew bundle install Give it a bit of time — a lot if you’re installing Xcode — and just like that most/all of your favorite software is installed. All in one easy peasy command line incantation.
  • Install Command Line Tools In order to install Homebrew, you need to install either the Xcode Command Line Tools (about 100 MB) or the full Xcode package (about 10 GB). In this tutorial, you will install Command Line Tools as they are a more reasonable size. Command Line Tools gives Mac users many commonly used tools, utilities, and compilers.

brew install <package>

Xcode可以从AppStore里下载安装,Command Line Tools for Xcode需要在终端中输入以下代码运行安装: xcode-select -install 安装Homebrew。.

Upgrading Homebrew and its packages can be done just as easily:

brew upgrade

but running this on Big Sur, with the latest version of Xcode (12.2) installed via the App Store will throw this error:

Your CLT does not support macOS 11.0

Xcode Beta

Log into Apple’s Developer Site and download the beta of Xcode, version 12.3 as of this writing. It’s an 11.5 GB ZIP file, which will take time to download. It also took at least 30 minutes to unzip on my machine and I have an SSD. Don’t just drop it into your Applicaitons folder, you’ll need to completely remove your existing install of Xcode from the app store. Take a look at this article for details. I don’t use Xcode other than for the CLT, so be careful and make backups before you start deleting things.

Once you’ve removed the version from the app store, drag the unzipped Xcode Beta into your Applications folder and run it. You’ll have to accept the license agreement to proceed. Once it’s up and running, run your Homebrew upgrade again.

Updated Command Line Tools

I immediately got the same message as before. Installing this beta was reported on multiple sites to have addressed the problem, but for me it didn’t. I forgot that there was command to specially check for issues with Homebrew:

brew doctor

Among others were these messages:

Running the softwareupdate command found nothing to install. So I followed the next pair of instructions:

Since these commands start with sudo, you’ll need to enter your user password so they’ll run. Another download began and the upgraded Command Line Tools were finally installed. If this doesn’t work for some reason, go to More Downloads for Apple Developers where you can download the DMG for “Command Line Tools for Xcode 12.3 beta” (430 MB). I’m not sure if you can run that without the main Xcode beta installed, but it’s worth a try in order to avoid the other large download. If anyone is able to run that without the main beta, please let me know.

Homebrew Xcode Outdated

Third Time’s the Charm

Homebrew Xcode Command Line Tools

And finally,

And there was much rejoicing! And I was finally able to start writing a new blog post.

Or so I thought.

Because updated software always runs perfectly the first time.

Homebrew List Installed Packages

Shyeah, right. (Jekyll, I’m looking at you.)

Homebrew and Apple Silicon

If you’re experiencing any other issues with Homebrew, check their Github account before freaking out. Not everything is currently supported on Big Sur, but they’re working on it. The other massive project in progress is supporting Apple Silicon. Take a look at macOS 11.0 Big Sur compatibility on Apple Silicon for more information.

And if you can spare something, make a donation. They deserve it.

If, like me, you tried installing imagemagick or other software using Homebrew, you might have ran into this error:

This took me one day to fix, because usually everyone tells you to run xcode-select --install. This does not fix the problem.

Why this happens

Mac OS X 10.14 has stopped placing the include libraries in their usual location, /usr/include, keeping them only inside the XCode directory.

Homebrew Xcode App

To confirm that this is the problem, simply run ls /usr/include. If the result comes out empty, its really this problem.

By running find / | grep libxml/parser.h I can find the libxml library in several places:

What you should not do

Some would say that you should just link the path where the libraries are to /usr/include. This is not right, as it overrides the default behaviour expected by Mac OS and requires you to disable SIP (System Integrity Protection). Sometimes it is needed, but this is not one of those times. Leave csrutil alone.

You CANNOT modify /usr/include, even with the root user. It is locked by SIP, so if you try you will get a Operation not permitted error.

What worked for me

Apple ships a “legacy installer” for you to be able to install the headers in the “old location”. Run this:

Then, the installer will be placed at your Destop. Simple double-click and it will install the headers in /usr/include.

or, if you want a pure command line alternative:

Problem fixed

The /usr/include directory now includes all the libraries required by brew to link during package compilation:

Now imagemagick and other kegs will install successfully.





Coments are closed