guix_mirror_bot pushed a commit to branch master
in repository guix.
commit abbf03a2efb4a8f3863ba5860e25657a557ea743
Author: Phillip Davis <[email protected]>
AuthorDate: Wed Mar 18 17:40:55 2026 -0400
import: gem: Fix null at home-page.
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.
(<gem>)[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 <[email protected]>
Signed-off-by: Nguyễn Gia Phong <[email protected]>
---
guix/import/gem.scm | 3 ++-
guix/import/pypi.scm | 6 ------
guix/import/utils.scm | 7 +++++++
tests/import/gem.scm | 40 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/guix/import/gem.scm b/guix/import/gem.scm
index 6acea10717..d7a6178846 100644
--- a/guix/import/gem.scm
+++ b/guix/import/gem.scm
@@ -63,7 +63,8 @@
(info gem-info)
(sha256 gem-sha256 "sha" ;bytevector
base16-string->bytevector)
- (home-page gem-home-page "homepage_uri") ;string
+ (home-page gem-home-page "homepage_uri" ;string | #f
+ non-empty-string-or-false)
(dependencies gem-dependencies "dependencies" ;<gem-dependencies>
json->gem-dependencies))
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index cb3b90368c..419662ec87 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -98,12 +98,6 @@
"pytest-isort" "pytest-flake8" "pytest-cov" "pytest-black" ; variants
"pytest-pep8" "pytest-mypy" "pytest-pep8" "pre-commit")) ;
-(define non-empty-string-or-false
- (match-lambda
- ("" #f)
- ((? string? str) str)
- ((or 'null #f) #f)))
-
;; PyPI project.
(define-json-mapping <pypi-project> make-pypi-project pypi-project?
json->pypi-project
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index c435981ca9..a9ff90f0ee 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -97,6 +97,7 @@
spdx-string->license
license->symbol
+ non-empty-string-or-false
snake-case
beautify-description
beautify-synopsis
@@ -470,6 +471,12 @@ object is bound to in the (guix licenses) module, such as
'license:gpl3+, or
(resolve-interface '(guix licenses) #:prefix 'license:)))
(assoc-ref licenses license))
+(define non-empty-string-or-false
+ (match-lambda
+ ("" #f)
+ ((? string? str) str)
+ ((or 'null #f) #f)))
+
(define (snake-case str)
"Return a downcased version of the string STR where underscores and periods
are replaced with dashes."
diff --git a/tests/import/gem.scm b/tests/import/gem.scm
index beee150875..dfa33d4036 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")