From 56a54e78425e181be289b07ce8e3ccba1a543c01 Mon Sep 17 00:00:00 2001 From: Joseph J Nuspl Jr Date: Sat, 27 Dec 2025 12:47:43 -0800 Subject: [PATCH] Strip hostnamectl icons In RHEL 10 (and other modern systemd-based distributions), the hostnamectl command has been updated to include visual icons using UTF-8 characters for the Chassis field. This change is part of the upstream systemd project's effort to make the CLI output more visually informative for users. Instead of just seeing the word "laptop" or "server," you now see a corresponding symbol. This leads to following: ``` warning: JSON.generate: UTF-8 string passed as BINARY, this will raise an encoding error in json 3.0 ``` Signed-off-by: Joseph J Nuspl Jr --- lib/ohai/plugins/linux/hostnamectl.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ohai/plugins/linux/hostnamectl.rb b/lib/ohai/plugins/linux/hostnamectl.rb index 8f16e2467..cfc729264 100644 --- a/lib/ohai/plugins/linux/hostnamectl.rb +++ b/lib/ohai/plugins/linux/hostnamectl.rb @@ -27,6 +27,10 @@ if hostnamectl_path shell_out(hostnamectl_path).stdout.split("\n").each do |line| key, val = line.split(": ", 2) + + # strip visual icons produced by newer versions of systemd + val.gsub!(/ [^[:ascii]]*$/, "") + hostnamectl[key.chomp.lstrip.tr(" ", "_").downcase] = val end end