I know there are a lot of questions about this gem but no answer has worked for me.
When I run in SSH gem install nokogiri I get this error:
<
I figured this out the hard way and took a few hours to follow the breadcrumbs and read up on what people were trying out. Nothing helped. Everything on this overflow page just didn't help so here's how I fixed this:
If you use your machine for other development projects that aren't in ruby. You might want to check package manager installations for other languages. More importantly - you might want to check for other c compiler installations - namely clang
In my case - I had installed anaconda/conda(python) and this replaced a bunch of paths in my .bash_profile to use clang as the main c compiler where as xcode command line tools and rebenv were all using gcc installed through Homebrew earlier.
I removed anaconda(using anaconda-clean) and the clang installation and then tried to bundle. That's when I got the missing libxml2 issue. I then REINSTALLED libxml2 through homebrew to ensure the symlinks would be redone through homebrew and followed the instructions that followed to add the appropriate export flags to my ~/bash_profile file.
Successfully bundles now. The reason is, the gems are now being bundled with the same compiler as the ruby version I am using for that project.
Docker would have made this a non issue for a polyglot dev machine like many of us I assume.
So heads up.