Installing Nokogiri on an M1 Mac

Featured image for sharing metadata for article

If you're working with Ruby projects, it's likely you'll have encountered Nokogiri.

Nokogiri, as a very powerful library for XML/HTML parsing, is used by many dependencies, but for Ruby devs is consistently an awkward thing to install, as it requires native extensions.

If you've got an M1 Mac, you may be hitting issues such as:

dlopen(.../nokogiri/.../nokogiri.bundle, ...): could not use '.../nokogiri-.../lib/nokogiri/.../nokogiri.bundle' because it is not a compatible arch - .../nokogiri-.../lib/nokogiri/.../nokogiri.bundle (LoadError)```

This is due to Bundler not picking up the platform's architecture correctly.

If you're on the default Ruby installation, which has a bundle --version below v2.1, you'll need to run, thanks to this comment on StackOverflow:

bundle config set force_ruby_platform true
bundle install

Or when using a Bundler version above v2.1:

bundle config force_ruby_platform true
bundle install

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #mac #ruby.

Also on:

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.