This is mainly just a quick reference for myself because I keep getting this error and have to search the internet for the solution. Basic problem is that on Ubuntu gems that use the nokogiri library for XML parsing require libxml2 which isn’t usually installed. When you try to install certain gems such as nokogiri or mechanize, either through gems directly or through bundler, get a message about missing dependencies – and when you wade a little deeper that libxml2 is missing. Solution sudo apt-get install libxml2 libxml2-dev libxslt1-dev This will install the dependencies and you can then install the gems using gem or bundler.