Skip to content

Instantly share code, notes, and snippets.

@leonardteo
Created December 27, 2016 22:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save leonardteo/9a128bc8ca983fa728aa08d8209e714a to your computer and use it in GitHub Desktop.
Save leonardteo/9a128bc8ca983fa728aa08d8209e714a to your computer and use it in GitHub Desktop.
For anyone trying to install maxmind_geoip2 on MacOS Sierra

You may run into probelms like this:

Building native extensions.  This could take a while...
ERROR:  Error installing maxmind_geoip2:
	ERROR: Failed to build gem native extension.

    current directory: /Users/leonardteo/.rvm/gems/ruby-2.1.6@artstation/gems/maxmind_geoip2-0.0.8/ext/maxmind_geoip2
/Users/leonardteo/.rvm/rubies/ruby-2.1.6/bin/ruby -r ./siteconf20161227-1647-1c4uejw.rb extconf.rb
checking for maxminddb.h... no
you must have mmdb library
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/Users/leonardteo/.rvm/rubies/ruby-2.1.6/bin/ruby

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/leonardteo/.rvm/gems/ruby-2.1.6@artstation/extensions/x86_64-darwin-16/2.1.0/maxmind_geoip2-0.0.8/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/leonardteo/.rvm/gems/ruby-2.1.6@artstation/gems/maxmind_geoip2-0.0.8 for inspection.
Results logged to /Users/leonardteo/.rvm/gems/ruby-2.1.6@artstation/extensions/x86_64-darwin-16/2.1.0/maxmind_geoip2-0.0.8/gem_make.out

The solution is to:

  1. Install libmaxminddb. Don't install the shitty Homebrew version! Install the real deal.
$ git clone --recursive https://github.com/maxmind/libmaxminddb
$ cd libmaxminddb
$ ./bootstrap
$ ./configure
$ make
$ make check
$ sudo make install

Note that ldconfig doesn't exist on OS X.

This should have installed libmaxminddb in /usr/local/include and /usr/local/lib.

  1. Pass the options into the gem install.
$ gem install maxmind_geoip2 -v '0.0.8' -- --with-opt-include=/usr/local/include --with-opt-lib=/usr/local/lib

You will see the following output:

Building native extensions with: '--with-opt-include=/usr/local/include --with-opt-lib=/usr/local/lib'
This could take a while...
Successfully installed maxmind_geoip2-0.0.8
Parsing documentation for maxmind_geoip2-0.0.8
Installing ri documentation for maxmind_geoip2-0.0.8
Done installing documentation for maxmind_geoip2 after 0 seconds
1 gem installed

WOOOYEAH!

@lucascaton
Copy link

Thanks!

My 2 cents: Homebrew version is now working perfectly (tested on macOS Big Sur - version 11.1).

@BrianSigafoos
Copy link

BrianSigafoos commented Jan 3, 2022

This was very helpful @leonardteo, thank you.

On a new Apple Silicon M1 ARM chip, without Rosetta, (macOS Monterey) I had to run this to manually install the maxmind_geoip2 first:

gem install maxmind_geoip2 -v '0.0.8' -- --with-opt-include=/opt/homebrew/include --with-opt-lib=/opt/homebrew/lib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment