From abbf03a2efb4a8f3863ba5860e25657a557ea743 Mon Sep 17 00:00:00 2001 From: Phillip Davis Date: Wed, 18 Mar 2026 17:40:55 -0400 Subject: import: gem: Fix null at home-page. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The RubyGems API returns "homepage_uri": null for gems with no homepage. guile-json parses JSON null as the Guile symbol 'null', which passes through into the generated package sexp as (home-page null)—an unbound variable error at evaluation time. * tests/import/gem.scm (test-no-homepage-json): New fixture. ("gem->guix-package, bald homepage_uri"): New test. * guix/import/gem.scm (non-empty-string-or-false): New procedure. ()[home-page]: Use it. * guix/import/utils.scm (non-empty-string-or-false): New exported procedure, moved to here... * guix/import/gem.scm (non-empty-string-or-false): ...from here... * guix/import/pypi.scm (non-empty-string-or-false): ...and here. Change-Id: If8f2ca32834d762c753797067ef87937503ff9f9 Reviewed-by: Carlo Zancanaro Signed-off-by: Nguyễn Gia Phong --- tests/import/gem.scm | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'tests') diff --git a/tests/import/gem.scm b/tests/import/gem.scm index beee1508756..dfa33d40366 100644 --- a/tests/import/gem.scm +++ b/tests/import/gem.scm @@ -112,6 +112,19 @@ \"licenses\": [\"MIT\"] }") +(define test-no-homepage-json + "{ + \"name\": \"no-homepage\", + \"version\": \"1.0.0\", + \"sha\": \"f3676eafca9987cb5fe263df1edf2538bf6dafc712b30e17be3543a9680547a8\", + \"info\": \"A gem with no homepage\", + \"homepage_uri\": null, + \"dependencies\": { + \"runtime\": [] + }, + \"licenses\": [\"MIT\"] +}") + (test-begin "gem") (test-assert "gem->guix-package" @@ -306,4 +319,31 @@ (list (upstream-source-urls source) (upstream-source-inputs source))))) +(test-assert "gem->guix-package, bald homepage_uri" + (mock ((guix http-client) http-fetch + (lambda (url . rest) + (match url + ("https://rubygems.org/api/v1/gems/no-homepage.json" + (values (open-input-string test-no-homepage-json) + (string-length test-no-homepage-json))) + (_ (error "Unexpected URL: " url))))) + (match (gem->guix-package "no-homepage") + (`(package + (name "ruby-no-homepage") + (version "1.0.0") + (source (origin + (method url-fetch) + (uri (rubygems-uri "no-homepage" version)) + (sha256 + (base32 + "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk")))) + (build-system ruby-build-system) + (synopsis "A gem with no homepage") + (description "This package provides a gem with no homepage.") + (home-page #f) + (license license:expat)) + #t) + (x + (pk 'fail x #f))))) + (test-end "gem") -- cgit v1.2.3