Xcode Install Mojave

Mojave

Download and install Xcode Command Line Tools (most recently tested version 11.2) from the App Store, or the full Xcode. If you installed full Xcode, you still need to type `xcode-select -install` to obtain the command line tools. Xcode is a complete developer toolset for creating apps for Mac, iPhone, iPad, Apple Watch, and Apple TV. Xcode brings user interface design, coding, testing, debugging, and submitting to the App Store into a unified workflow. Downloading and updating Xcode. The current release of Xcode is available as a free download from the Mac App Store.

Welcome! We've spent quite a bit of time over the past year trying to make Nokogiri v1.11 easy and reliable to install. This page should hopefully get you on your way quickly.

Meta¶

Sudo apt-get install build-essential AMD64 (64 bits) users will need to download and install additional packages to target the i386 (32 bits) architecture, this can be done with this command in a terminal: sudo apt-get install gcc-multilib g-multilib Step Two: Preparing the Source SDK 2013. Always make sure to install the latest available version of Xcode for your macOS release; using outdated versions of Xcode may cause port install failures. Also note that Xcode is not updated via OS X's Software Update utility on OS versions prior to 10.6, and is updated via the Mac App Store starting with 10.7. Feb 12, 2014 From MacOS Monterey, Big Sur, Catalina, Mojave, High Sierra, Sierra, OS X El Capitan, Yosemite, Mavericks onward, this is now easily possible directly and without installing the entire Xcode package first, no developer account is required either.

The current version of this page focuses on the installation experience for Nokogiri v1.11.x. If you're trying to install an earlier version, please visit:

If this document doesn't address your problem, please jump over to Getting Help.

If you'd like to contribute improvements to this document, please open a GitHub issue or pull-request on nokogiri.org/installing_nokogiri.md.

Installing Native Gems¶

Faster, more reliable installation¶

'Native gems' contain pre-compiled libraries for a specific machine architecture. On supported platforms, this removes the need for compiling the C extension and the packaged libraries, or for system dependencies to exist. This results in much faster installation and more reliable installation, which as you probably know are the biggest headaches for Nokogiri users.

Supported Platforms¶

As of v1.11.0, Nokogiri ships pre-compiled, 'native' gems for the following platforms:

  • Linux: x86-linux and x86_64-linux (req: glibc >= 2.17), including musl platforms like Alpine
  • Darwin/MacOS: x86_64-darwin and arm64-darwin
  • Windows: x86-mingw32 and x64-mingw32
  • Java: any platform running JRuby 9.2 or higher

To determine whether your system supports one of these gems, look at the output of bundle platform or ruby -e 'puts Gem::Platform.local.to_s'.

If you're on a supported platform, either gem install or bundle install should install a native gem without any additional action on your part. This installation should only take a few seconds, and your output should look something like:

Why would I not want to use a native gem?¶

I can imagine some folks might have trust issues; if this is you, please let us know in a comment at RFC: Increase the level of trust in released gem files · Issue #2013 · sparklemotion/nokogiri. What can we do to increase that trust? (I can imagine providing a chain of custody including public build logs with cryptographic hashes of artifacts, but I'd like to hear from real users.)

Anybody on a linux system old enough to not have glibc >= 2.17 will need to install from the ruby platform gem.

If you have other reasons for not wanting to use a precompiled native gem, let us know! (See Getting Help.)

How can I avoid using a precompiled native gem?¶

The Nokogiri maintainers strongly urge you to use a native gem if at all possible. We expect it will be a much better experience for you and allow us to focus our efforts on improving functionality rather than diagnosing installation issues.

If you're on a platform that supports a native gem but you want to avoid using it in your project, do one of the following:

  • If you're not using Bundler, then run gem install nokogiri --platform=ruby
  • If you are using Bundler
  • version 2.1 or later, then you'll need to run bundle config set force_ruby_platform true,
  • version 2.0 or earlier, then you'll need to run bundle config force_ruby_platform true
Mac

Installing the ruby platform gem¶

Again, we recommend that you upgrade to v1.11.x and use a native gem whenever possible. If you're here, it should be because you're on an older version, or you're on an unsupported platform.

Before you begin, make sure you have the full compiler toolchain for compiling Ruby C Extensions. See Appendix A: The Compiler Toolchain.

Installing Using The Packaged Libraries¶

Nokogiri packages its own updated and patched copies of libxml2 and libxslt source code. By default, installation of Nokogiri will compile and use these packaged libraries.

If you don't see your operating system / distro in this section, then no additional setup is required beyond Appendix A: The Compiler Toolchain. Just run gem install nokogiri --platform=ruby.

Ubuntu or Debian-based Distros¶

You may substitute git for patch (mini_portile2 can use either for applying patches).

Fedora, Red Hat, and CentOS¶

OpenBSD < 6.2¶

Use gcc from ports in order to compile the packaged libraries:

Installing Using Standard System Libraries¶

Rather than use Nokogiri's packaged versions, you may prefer to use your system's or distro's standard libxml2/libxslt libraries. This section will try to help you do that.

Nokogiri will refuse to build against older, unsupported versions of libxml2 and libxslt, and there may be some behavioral changes when using older versions. If you have installed libxml2 or libxslt to a custom location, please jump to the next section, Installing With Custom / Non-Standard Libraries.

If you don't see your operating system or distro listed below, then no additional setup is required beyond Appendix A: The Compiler Toolchain. Just run gem install nokogiri --platform=ruby -- --use-system-libraries. Or, if you're using bundler, bundle config build.nokogiri --use-system-libraries.

Debian/Ubuntu¶

MacOS¶

If you're using homebrew:

If you're using macports and would like to contribute documentation, please open a GitHub issue or pull-request on nokogiri.org/installing_nokogiri.md.

FreeBSD¶

Windows¶

We recommend installing Nokogiri against the MSYS2 system libraries:

Installing With Custom / Non-Standard Libraries¶

You may have your own custom version of libxml2/libxslt that you'd like to use. OK! Here we go.

Ideally you can install pkg-config and the installed libraries should self-describe how to compile and build against themselves.

Install Xcode 11.3 On Mojave

But if:

  • you've got libxml2 and/or libxslt installed in a nonstandard place,
  • and you don't have pkg-config installed

... then you can use command-line parameters to the gem install command to specify build parameters.

You can specify the installation root directory:

or, you can specify include and library directories separately:

Note: By default, libxslt header files are installed into the root include directory, but libxml2 header files are installed into a subdirectory thereof named libxml2.

It's likely that you'll also need to specify the location of your zlib and iconv (and possibly exslt) install directories as well. In that case, you can add the options:

You can also tell bundler to remember these configuration parameters:

Do not attempt Bundler installation using Bundler versions before v1.8.3 (see bundler/bundler#3053 for details). If you really must, see earlier git history of this file, which includes a workaround.

Installing Third-Party Distributions of Nokogiri¶

Debian¶

See https://packages.debian.org/sid/ruby-nokogiri

openSUSE/SLE¶

See https://download.opensuse.org/repositories/devel:/languages:/ruby:/extensions/

Fedora, Red Hat, and CentOS¶

You may install the appropriate epel-release and get the Nokogiri package from EPEL using:

GNU Guix¶

Install on any Linux distribution using GNU Guix, a reproducible binary software package management and distribution system.

Use this command:

Note: source code is available here. A short description of how Nokogiri was packaged can be found here.

Other Installation Scenarios¶

Alpine Docker Images¶

To just install the native gem:

To compile with the packaged libraries:

To compile against Alpine's own XML libraries, add the necessary development tools and libraries to the image.

When optimizing the size of an Alpine image, the runtime libraries must be permanently added. Additionally, adding and removing development tooling can be chained with gem installation to ensure a small layer.

This approach nets an 12.1 MB layer (versus 18.1 MB without --use-system-libraries)and saves over 170 MB in build tools.

TermUX¶

Although TermUX isn't fully supported right now, some people have reported success getting Nokogiri installed on it by running these commands:

SmartOS (Nonstandard)¶

SmartOS installation requires building and using libxml2/libxslt/libiconv in a nonstandard location. Building on the previous section, here's how to do it:

(Note: pkgsrc is included in JPC SmartOS instances)

See the previous section for guidance on how to instruct Bundler to use these options.

Troubleshooting¶

Using vendor/cache to deploy to another architecture¶

A common workflow is for a team to develop on a Mac but deploy to production on Linux. This workflow depends on Bundler caching an appropriate gem file in vendor/cache. Unfortunately, in this situation Bundler's default behavior is to cache only gems for the development system and not the production system, leading to an error at deploy time.

Symptoms¶

During deployment, the buildpack may fail to find a relevant gem in vendor/cache and emit an error like this (from Heroku):

Solution¶

Bundler 2.2 and later has great multiplatform support and allows you to cache gems for multiple platforms. You can run commands like these to cause Bundler to fetch and cache gems for all the named platforms:

For more information, please read this wonderful blog post written by Kevin Murphy explaining this approach.

Fallback Solution¶

If you can't upgrade to Bundler 2.2 (or later), you can force older versions to always use the ruby platform, which supports all platforms, but applies to all gems and comes with the installation challenges mentioned earlier in this guide.

Here's how to do this with Bundler 2.1 or later:

Or if you're on version 2.0 or earlier:

Cannot install racc

As of v1.11.0, Nokogiri is declaring an explicit dependency on racc ~> 1.4, which itself is a C extension that users may have trouble installing.

Symptoms¶

You may see an error message like this:

Solution 1 - Compiler toolchain¶

Racc needs the same compiler toolchain to be present as any Gem with a C extension. See Appendix A: The Compiler Toolchain.

Solution 2 - Avoid installing Racc¶

Ruby 3.0 comes with Racc 1.5.x as a 'builtin gem', so you could update to Ruby 3!

Ruby 2.7 comes with Racc 1.4.x as a 'builtin gem', so you could use that version instead of trying to upgrade. Update to Ruby 2.7 and add a line like gem 'racc', '~> 1.4.0' to prevent bundler from trying to upgrade.

[Linux] /usr/bin/ld: cannot find -lgmp

If you're compiling the ruby platform gem, and if you've installed Ruby using RVM, you may require libgmp.

Symptoms¶

Gem installation fails with an error message like:

And examination of your mkmf.log file shows:

Solution¶

Run sudo apt-get install libgmp-dev.

[MacOS] xcode-select errors with a 'network problem'¶

If you're compiling the ruby platform gem ...

Symptoms¶

You see this dialog when you run the commands to update xcode commandline tools:

Solution¶

Run this command to turn off forced-authentication with Apple Software Update:

[MacOS] error: use of undeclared identifier 'LZMA_OK'

If you're compiling the ruby platform gem ...

Symptoms¶

An error during Nokogiri installation mentions an undeclared identifier LZMA_OK:

Xcode Install Mojave Free

Diagnosis¶

When using Homebrew, there are several libraries that use a formula called xz (including the_silver_searcher and imagemagick), which by default install a version of liblzma that is incompatible with most Ruby builds. (Homebrew installs only the 64-bit version of the library, but most Ruby builds are universal.) This can be fixed in a couple of ways:

Solution 1¶

The most reliable solution appears to be temporarily unlinking xz and relinking it during an install of nokogiri:

Solution 2¶

The other solution is to use a Homebrew-installed libxml2, as suggested in Installing Using Standard System Libraries.

or if you're using bundler:

When working with this, be certain to use $(brew --prefix libxml2) because it will use the correct location for your Homebrew install.

[MacOS] libiconv is missing

Xcode 10 on macOS Mojave moves the system headers out of /usr/include and so Nokogiri will fail to build when you're compiling the ruby platform gem.

Symptoms¶

You'll see an error similar to this:

Solution¶

A temporary workaround to allow previous releases of Nokogiri to build is to install the extra headers package mentioned in the Xcode 10 release notes:

You can also install the headers package from the command line (e.g. for a build script or a CI server):

[MacOS] General MacOS Tips¶

If you're seeing other problems:

Macos Mojave Xcode Install

  • Make sure ruby is compiled with the latest clang compiler.
  • Binary gems and ruby should be compiled with the same compiler/environment.
  • If you have multiple versions of Xcode installed, make sure you use the right xcode-select.
  • Try Installing Using Standard System Libraries.

Appendix A: The Compiler Toolchain¶

A good way to tell if you've got your basic Ruby C extension compiler toolchain installed correctly is to try installing the bcrypt gem which has a smaller, self-contained C extension. If you can gem install bcrypt, you're all set!

Reminder: if you're installing a native gem, you don't need to do this.

Ubuntu or Debian-based Distros¶

Fedora, Red Hat, and CentOS¶

Alpine¶

Windows¶

Xcode install mojave os

Please visit RubyInstaller and make sure you install a version 'With Devkit'.

Xcode Install Mac Mojave

MacOS¶

First, make sure you have the latest version of RubyGems and xcode commandline tools:

Xcode Install Mojave Windows 10

Agree to the Xcode license: