From d01d7d995ddf4a5cb689ca3cac2a3bc00b995d4f Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Thu, 31 Dec 2020 12:46:57 -0500 Subject: [PATCH] fix: emit helpful error when native gem fails to load glibc Specifically, older systems may not meet our expectations for glibc, and this commit attempts to help those poor souls find a path forward. I manually tested this change using the OCI image at: registry.gitlab.com/gitlab-org/gitlab-omnibus-builder/centos_6:0.0.72 Closes #2081 --- lib/nokogiri.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/nokogiri.rb b/lib/nokogiri.rb index 20f383840e..a548e8bf1d 100644 --- a/lib/nokogiri.rb +++ b/lib/nokogiri.rb @@ -11,7 +11,24 @@ begin RUBY_VERSION =~ /(\d+\.\d+)/ require "nokogiri/#{$1}/nokogiri" -rescue LoadError +rescue LoadError => e + if e.message =~ /GLIBC/ + warn <<~EOM + + ERROR: It looks like you're trying to use Nokogiri as a precompiled native gem on a system with glibc < 2.17: + + #{e.message} + + If that's the case, then please install Nokogiri via the `ruby` platform gem: + gem install nokogiri --platform=ruby + or: + bundle config set force_ruby_platform true + + Please visit https://nokogiri.org/tutorials/installing_nokogiri.html for more help. + + EOM + raise e + end require 'nokogiri/nokogiri' end require 'nokogiri/version'