MELPA importer uses the wrong source when called from CLI

DoneSubmitted by Xinglu Chen.
Details
2 participants
  • Ludovic Courtès
  • Xinglu Chen
Owner
unassigned
Severity
normal
X
X
Xinglu Chen wrote on 13 Jun 2021 18:20
(address . bug-guix@gnu.org)
87fsxl91oh.fsf@yoctocell.xyz
When importing a package from MELPA, the source for generated package
definition points to a (potentially unstable?) MELPA URL.


Toggle snippet (42 lines)
~/src/guix [env]$ ./pre-inst-env guix import elpa -a melpa magit

Starting download of /tmp/guix-file.wbtAlA
From https://melpa.org/packages/magit-20210609.2000.tar...
…609.2000.tar 1.7MiB 472KiB/s 00:04 [##################] 100.0%
(package
(name "emacs-magit")
(version "20210609.2000")
(source
(origin
(method url-fetch)
(uri (string-append
"https://melpa.org/packages/magit-"
version
".tar"))
(sha256
(base32
"0pplizxy20i3i9zqm5kfjz4la93gpz8wwh1ybwdwngv5ks7vhdsr"))))
(build-system emacs-build-system)
(propagated-inputs
`(("emacs-dash" ,emacs-dash)
("emacs-git-commit" ,emacs-git-commit)
("emacs-magit-section" ,emacs-magit-section)
("emacs-transient" ,emacs-transient)
("emacs-with-editor" ,emacs-with-editor)))
(home-page "https://github.com/magit/magit")
(synopsis "A Git porcelain inside Emacs.")
(description
"Magit is a text-based Git user interface that puts an unmatched focus
on streamlining workflows. Commands are invoked using short mnemonic
key sequences that take the cursor’s position in the highly actionable
interface into account to provide context-sensitive behavior.

With Magit you can do nearly everything that you can do when using Git
on the command-line, but at greater speed and while taking advantage
of advanced features that previously seemed too daunting to use on a
daily basis. Many users will find that by using Magit they can become
more effective Git user.
")
(license #f))

However, looking at (guix import elpa), it has a ‘melpa-recipe->origin’
procedure, which calls the ‘git-repository->origin’ procedure, which
returns an origin that uses ‘git-fetch’.

#+begin_src scheme
(define (git-repository->origin recipe url)
"Fetch origin details from the Git repository at URL for the provided MELPA
RECIPE."
(define ref
(cond
((assoc-ref recipe #:branch)
=> (lambda (branch) (cons 'branch branch)))
((assoc-ref recipe #:commit)
=> (lambda (commit) (cons 'commit commit)))
(else
'(branch . "master"))))

(let-values (((directory commit) (download-git-repository url ref)))
`(origin
(method git-fetch)
(uri (git-reference
(url ,url)
(commit ,commit)))
(sha256
(base32
,(bytevector->nix-base32-string
(file-hash directory (negate vcs-file?) #t)))))))

(define* (melpa-recipe->origin recipe)
"Fetch origin details from the MELPA recipe and associated repository for
the package named PACKAGE-NAME."
(define (github-repo->url repo)
(string-append "https://github.com/"repo ".git"))
(define (gitlab-repo->url repo)
(string-append "https://gitlab.com/"repo ".git"))

(match (assq-ref recipe ':fetcher)
('github (git-repository->origin recipe (github-repo->url (assq-ref recipe ':repo))))
('gitlab (git-repository->origin recipe (gitlab-repo->url (assq-ref recipe ':repo))))
('git (git-repository->origin recipe (assq-ref recipe ':url)))
(#f #f) ; if we're not using melpa then this stops us printing a warning
(_ (warning (G_ "Unsupported MELPA fetcher: ~a, falling back to unstable MELPA source.~%")
(assq-ref recipe ':fetcher))
#f)))
#+end_src

‘melpa-recipe->origin’ is used in the ‘elpa-package->sexp’ procedure,
and takes precedence over the ‘url-fetch’ origin. Meaning that
‘melpa-source’ must have been #f, otherwise it shouldn’t have used
’url-fetch’.

#+begin_src scheme
(define melpa-source
(melpa-recipe->origin melpa-recipe))

(values
`(package
(name ,(elpa-name->package-name name))
(version ,version)
(source ,(or melpa-source ;here
(let ((tarball (with-store store
(download-to-store store source-url))))
`(origin
(method url-fetch)
(uri (string-append ,@(factorize-uri source-url version)))
(sha256
(base32
,(if tarball
(bytevector->nix-base32-string (file-sha256 tarball))
"failed to download package")))))))
...))
#+end_src

What’s weird is that calling ‘elpa->guix-package’ in the REPL generates
a package definition that uses ’git-fetch’ instead of ’url-fetch’

Toggle snippet (5 lines)
scheme@(guile-user)> ,use(guix import elpa)
scheme@(guile-user)> (elpa->guix-package "magit" #:repo 'melpa)
$2 = (package (name "emacs-magit") (version "20210609.2000") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/magit/magit.git") (commit "71f57c5582448be81b02ba53750dd2ea39ed0eaf"))) (sha256 (base32 "16ip50a46nk6xxj8qkpf6rmp28zjc1bhyjj9bfgibim8ywj87dlq")))) (build-system emacs-build-system) (propagated-inputs (quasiquote (("emacs-dash" (unquote emacs-dash)) ("emacs-git-commit" (unquote emacs-git-commit)) ("emacs-magit-section" (unquote emacs-magit-section)) ("emacs-transient" (unquote emacs-transient)) ("emacs-with-editor" (unquote emacs-with-editor))))) (arguments (quote (#:include (quote ("^lisp/magit$" "^lisp/magit[^/]+.el$" "^lisp/git-rebase.el$" "^Documentation/magit.texi$" "^Documentation/AUTHORS.md$" "^LICENSE$")) #:exclude (quote ("^lisp/magit-libgit.el$" "^lisp/magit-section.el$"))))) (home-page "https://github.com/magit/magit") (synopsis "A Git porcelain inside Emacs.") (description "Magit is a text-based Git user interface that puts an unmatched focus\non streamlining workflows. Commands are invoked using short mnemonic\nkey sequences that take the cursor’s position in the highly actionable\ninterface into account to provide context-sensitive behavior.\n\nWith Magit you can do nearly everything that you can do when using Git\non the command-line, but at greater speed and while taking advantage\nof advanced features that previously seemed too daunting to use on a\ndaily basis. Many users will find that by using Magit they can become\nmore effective Git user.\n") (license license:gpl3+))
$3 = ("dash" "git-commit" "magit-section" "transient" "with-editor")
-----BEGIN PGP SIGNATURE-----

iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmDGMD4VHHB1YmxpY0B5
b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5JEsP/R0HWNNasONb0TW0cQa+QvHook6D
9s87poLRSnWiHwH50d68VHNoxd6D4a59F9Xpa/pncEvThDEp58LR7IrwxnpCjymR
aPDETDz6gRJFLwhmCUBqcxLlm4SpOv6NyhVbSXJSs6vF/C8Dt3OR+VzVf6Itp5hP
1snFdK6HzRyLV5U2adLUkc7sFsAZjuQZP/9F8HfcxQoZ2Q7YQUNPWONMl4gtIJaR
ru5U+ToOvGicG6fyQylH7wvVY63JCid+9sHiirftJFYHeiL00cWTPYp5m1r9g+LR
2L0QY25tURCu/2pfw92mFRJ034olzrKgpdL81gIeyW9e8L0gmo6BUcf7yD8sh+yk
pw53JVYyx1vpJnPPoTyienDwoFM8gIcEwI5epUMYE/ZpJ+3RNHQ6GUwMMykLhHE2
CkKyRSu8Uh7VVimoYiKB0TTeV+5tMjOJvMi7kiXB6ZneEKsohepbsgQKo9swoJYG
tuoPfFl1bg+bO2ajPwzieq9DnK2ONata/ma7Z0qN1tJcrV121LKiaJFzSCFdQzcl
+U32dQIpx+kauAScyrtyfPQa8r+sTnnLM3B5hq3oWvWudecIkATrYlmjU6I7iqqR
gbvQNH8JQ6roKJNPviKmxkUrOH4aV9IYeCMe05lFNhzYz+4U49VsVCSOLRdnTEb0
zJmeFYABXsrjCOAT
=pWry
-----END PGP SIGNATURE-----

X
X
Xinglu Chen wrote on 13 Jun 2021 20:11
(address . 49006@debbugs.gnu.org)
87czsp8wic.fsf@yoctocell.xyz
Okay, so new findings:

When the (guix import elpa) module has been compiled, the generated
package definition uses ‘url-fetch’ to fetch the source.

Toggle snippet (42 lines)
~/src/guix [env]$ ./pre-inst-env guix import elpa -a melpa magit

Starting download of /tmp/guix-file.US750W
From https://melpa.org/packages/magit-20210609.2000.tar...
…609.2000.tar 1.7MiB 365KiB/s 00:05 [##################] 100.0%
(package
(name "emacs-magit")
(version "20210609.2000")
(source
(origin
(method url-fetch)
(uri (string-append
"https://melpa.org/packages/magit-"
version
".tar"))
(sha256
(base32
"0pplizxy20i3i9zqm5kfjz4la93gpz8wwh1ybwdwngv5ks7vhdsr"))))
(build-system emacs-build-system)
(propagated-inputs
`(("emacs-dash" ,emacs-dash)
("emacs-git-commit" ,emacs-git-commit)
("emacs-magit-section" ,emacs-magit-section)
("emacs-transient" ,emacs-transient)
("emacs-with-editor" ,emacs-with-editor)))
(home-page "https://github.com/magit/magit")
(synopsis "A Git porcelain inside Emacs.")
(description
"Magit is a text-based Git user interface that puts an unmatched focus
on streamlining workflows. Commands are invoked using short mnemonic
key sequences that take the cursor’s position in the highly actionable
interface into account to provide context-sensitive behavior.

With Magit you can do nearly everything that you can do when using Git
on the command-line, but at greater speed and while taking advantage
of advanced features that previously seemed too daunting to use on a
daily basis. Many users will find that by using Magit they can become
more effective Git user.
")
(license #f))

However, if the (guix import elpa) module hasn’t been compiled, say I
just add a dummy comment to it, then the generated package definition
uses ‘git-fetch’ instead of ‘url-fetch’. Notice the messages emitted by
Guile.

Toggle snippet (61 lines)
~/src/guix [env]$ ./pre-inst-env guix import elpa -a melpa magit
;;; note: source file /home/yoctocell/src/guix/guix/import/elpa.scm
;;; newer than compiled /home/yoctocell/src/guix/guix/import/elpa.go
;;; note: source file /home/yoctocell/src/guix/guix/import/elpa.scm
;;; newer than compiled /home/yoctocell/.config/guix/current/lib/guile/3.0/site-ccache/guix/import/elpa.go
;;; note: source file /home/yoctocell/src/guix/guix/import/elpa.scm
;;; newer than compiled /home/yoctocell/.guix-home/profile/lib/guile/3.0/site-ccache/guix/import/elpa.go
;;; note: source file /home/yoctocell/src/guix/guix/import/elpa.scm
;;; newer than compiled /home/yoctocell/.config/guix/current/lib/guile/3.0/site-ccache/guix/import/elpa.go
;;; note: source file /home/yoctocell/src/guix/guix/import/elpa.scm
;;; newer than compiled guix/import/elpa.go
;;; note: source file /home/yoctocell/src/guix/guix/import/elpa.scm
;;; newer than compiled /home/yoctocell/.cache/guile/ccache/3.0-LE-8-4.5/home/yoctocell/src/guix/guix/import/elpa.scm.go
(package
(name "emacs-magit")
(version "20210609.2000")
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/magit/magit.git")
(commit
"71f57c5582448be81b02ba53750dd2ea39ed0eaf")))
(sha256
(base32
"16ip50a46nk6xxj8qkpf6rmp28zjc1bhyjj9bfgibim8ywj87dlq"))))
(build-system emacs-build-system)
(propagated-inputs
`(("emacs-dash" ,emacs-dash)
("emacs-git-commit" ,emacs-git-commit)
("emacs-magit-section" ,emacs-magit-section)
("emacs-transient" ,emacs-transient)
("emacs-with-editor" ,emacs-with-editor)))
(arguments
'(#:include
'("^lisp/magit$"
"^lisp/magit[^/]+.el$"
"^lisp/git-rebase.el$"
"^Documentation/magit.texi$"
"^Documentation/AUTHORS.md$"
"^LICENSE$")
#:exclude
'("^lisp/magit-libgit.el$"
"^lisp/magit-section.el$")))
(home-page "https://github.com/magit/magit")
(synopsis "A Git porcelain inside Emacs.")
(description
"Magit is a text-based Git user interface that puts an unmatched focus
on streamlining workflows. Commands are invoked using short mnemonic
key sequences that take the cursor’s position in the highly actionable
interface into account to provide context-sensitive behavior.

With Magit you can do nearly everything that you can do when using Git
on the command-line, but at greater speed and while taking advantage
of advanced features that previously seemed too daunting to use on a
daily basis. Many users will find that by using Magit they can become
more effective Git user.
")
(license #f))

Maybe there is some problem with Guile itself?
-----BEGIN PGP SIGNATURE-----

iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmDGSmsVHHB1YmxpY0B5
b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x5b8oP+wTVXlFENDq0VOXR5U3z/nCrvHFe
0XASR77E63n3hHaH+4VEnASHHnGBI/KmMwFtwSLU1MXfC4tQ7dPEDrBsOqm0QfbB
HnVIjdo+DKf7+jSQFAwKD067F5Mts5+92lZuveanmd2MtLHGK5iYHJ0xkZOjW/p4
fulftakDSWNbG8JdC9nPQgbx26IeFR+0kX3Y8vkuzcTOor11HE98Bp4bzBzo+yZ3
Bl17dQY35VLFmkfXCdKDlx6uxLOxWR9XxMbADKznlegxy6HTU+zB2X5PIOnhYjoy
jt275h0aY0sHKHpVG5HUGk+wHQlcHetROXNRz2Ri0yj1LOhCAq7ZtMfmbRWEQwrx
SZ5ZwVEC1kfHrR9auUm6C3eMTOJfYsV+AQpasUfDFpYTrIKr9OF0eiQoaPVcq1MM
Zfpa7rYRO9xcHtHviJIA0W0WJXVOyX5rSOuOhPZyjmBCJxSNj5FT7LoWc7pQjwzS
abJHwpjBeitHdH/+9amqqtZMqcd6e1J0uOq/fxniaL4GWkiURHDjXiMkvGlgqYgC
MlQv+dFZVSMcXJnu2Mr5XT+eGvHZrm+b3vOh6O47ayAxYAuY43dWc6UOtMbZ0Mrx
eIOYFCgR+nIjwln7MNwRrMGxzx+C5McF0FRO4Yfc9y3XpmJyVkbiByi58VBhuKDV
FmmW27NAcBAZLKXh
=JWgp
-----END PGP SIGNATURE-----

X
X
Xinglu Chen wrote on 6 Sep 2021 13:08
(address . 49006@debbugs.gnu.org)
87fsui2c72.fsf@yoctocell.xyz
On Sun, Jun 13 2021, Xinglu Chen wrote:

Toggle quote (117 lines)
> Okay, so new findings:
>
> When the (guix import elpa) module has been compiled, the generated
> package definition uses ‘url-fetch’ to fetch the source.
>
> --8<---------------cut here---------------start------------->8---
> ~/src/guix [env]$ ./pre-inst-env guix import elpa -a melpa magit
>
> Starting download of /tmp/guix-file.US750W
> From https://melpa.org/packages/magit-20210609.2000.tar...
> …609.2000.tar 1.7MiB 365KiB/s 00:05 [##################] 100.0%
> (package
> (name "emacs-magit")
> (version "20210609.2000")
> (source
> (origin
> (method url-fetch)
> (uri (string-append
> "https://melpa.org/packages/magit-"
> version
> ".tar"))
> (sha256
> (base32
> "0pplizxy20i3i9zqm5kfjz4la93gpz8wwh1ybwdwngv5ks7vhdsr"))))
> (build-system emacs-build-system)
> (propagated-inputs
> `(("emacs-dash" ,emacs-dash)
> ("emacs-git-commit" ,emacs-git-commit)
> ("emacs-magit-section" ,emacs-magit-section)
> ("emacs-transient" ,emacs-transient)
> ("emacs-with-editor" ,emacs-with-editor)))
> (home-page "https://github.com/magit/magit")
> (synopsis "A Git porcelain inside Emacs.")
> (description
> "Magit is a text-based Git user interface that puts an unmatched focus
> on streamlining workflows. Commands are invoked using short mnemonic
> key sequences that take the cursor’s position in the highly actionable
> interface into account to provide context-sensitive behavior.
>
> With Magit you can do nearly everything that you can do when using Git
> on the command-line, but at greater speed and while taking advantage
> of advanced features that previously seemed too daunting to use on a
> daily basis. Many users will find that by using Magit they can become
> more effective Git user.
> ")
> (license #f))
> --8<---------------cut here---------------end--------------->8---
>
> However, if the (guix import elpa) module hasn’t been compiled, say I
> just add a dummy comment to it, then the generated package definition
> uses ‘git-fetch’ instead of ‘url-fetch’. Notice the messages emitted by
> Guile.
>
> --8<---------------cut here---------------start------------->8---
> ~/src/guix [env]$ ./pre-inst-env guix import elpa -a melpa magit
> ;;; note: source file /home/yoctocell/src/guix/guix/import/elpa.scm
> ;;; newer than compiled /home/yoctocell/src/guix/guix/import/elpa.go
> ;;; note: source file /home/yoctocell/src/guix/guix/import/elpa.scm
> ;;; newer than compiled /home/yoctocell/.config/guix/current/lib/guile/3.0/site-ccache/guix/import/elpa.go
> ;;; note: source file /home/yoctocell/src/guix/guix/import/elpa.scm
> ;;; newer than compiled /home/yoctocell/.guix-home/profile/lib/guile/3.0/site-ccache/guix/import/elpa.go
> ;;; note: source file /home/yoctocell/src/guix/guix/import/elpa.scm
> ;;; newer than compiled /home/yoctocell/.config/guix/current/lib/guile/3.0/site-ccache/guix/import/elpa.go
> ;;; note: source file /home/yoctocell/src/guix/guix/import/elpa.scm
> ;;; newer than compiled guix/import/elpa.go
> ;;; note: source file /home/yoctocell/src/guix/guix/import/elpa.scm
> ;;; newer than compiled /home/yoctocell/.cache/guile/ccache/3.0-LE-8-4.5/home/yoctocell/src/guix/guix/import/elpa.scm.go
> (package
> (name "emacs-magit")
> (version "20210609.2000")
> (source
> (origin
> (method git-fetch)
> (uri (git-reference
> (url "https://github.com/magit/magit.git")
> (commit
> "71f57c5582448be81b02ba53750dd2ea39ed0eaf")))
> (sha256
> (base32
> "16ip50a46nk6xxj8qkpf6rmp28zjc1bhyjj9bfgibim8ywj87dlq"))))
> (build-system emacs-build-system)
> (propagated-inputs
> `(("emacs-dash" ,emacs-dash)
> ("emacs-git-commit" ,emacs-git-commit)
> ("emacs-magit-section" ,emacs-magit-section)
> ("emacs-transient" ,emacs-transient)
> ("emacs-with-editor" ,emacs-with-editor)))
> (arguments
> '(#:include
> '("^lisp/magit$"
> "^lisp/magit[^/]+.el$"
> "^lisp/git-rebase.el$"
> "^Documentation/magit.texi$"
> "^Documentation/AUTHORS.md$"
> "^LICENSE$")
> #:exclude
> '("^lisp/magit-libgit.el$"
> "^lisp/magit-section.el$")))
> (home-page "https://github.com/magit/magit")
> (synopsis "A Git porcelain inside Emacs.")
> (description
> "Magit is a text-based Git user interface that puts an unmatched focus
> on streamlining workflows. Commands are invoked using short mnemonic
> key sequences that take the cursor’s position in the highly actionable
> interface into account to provide context-sensitive behavior.
>
> With Magit you can do nearly everything that you can do when using Git
> on the command-line, but at greater speed and while taking advantage
> of advanced features that previously seemed too daunting to use on a
> daily basis. Many users will find that by using Magit they can become
> more effective Git user.
> ")
> (license #f))
> --8<---------------cut here---------------end--------------->8---
>
> Maybe there is some problem with Guile itself?

I came up with a hack to fix the issue, see the diff below

diff --git a/guix/import/elpa.scm b/guix/import/elpa.scm
index c0dc5acf51..0d07b4b35e 100644
--- a/guix/import/elpa.scm
+++ b/guix/import/elpa.scm
@@ -335,7 +335,8 @@ the package named PACKAGE-NAME."
type '<elpa-package>'."
(define melpa-recipe
- (if (eq? repo 'melpa)
+ ;; XXX: Otherwise (eq? repo 'melpa) always seems to return #f.
+ (if (force (delay (eq? repo 'melpa)))
(package-name->melpa-recipe (elpa-package-name pkg))
#f))
I am not sure if this is a good workaround, though. Any thoughts?
-----BEGIN PGP SIGNATURE-----

iQJJBAEBCAAzFiEEAVhh4yyK5+SEykIzrPUJmaL7XHkFAmE19sEVHHB1YmxpY0B5
b2N0b2NlbGwueHl6AAoJEKz1CZmi+1x55aEP/RAOmMLSPEVQC1xkWgy42VWhRJoj
vGXamThwtMXYf6ugtZjKp1cRzf+Hg6zGHjNheSgzA1NNi+cga0n+coKlzeMPKiTM
IvZLrJPXQMK5w/fCPEguLS+GRQlXF0hmFvgKS8LxaYxSBvMHexmqxLvSmR9iiaLq
xHdK3mxVu3NtLsbasVZ3MZzmhKuQPEXgqT0OMgaS8BfNlrB359bLBE/k9X8pS2Hc
Io/DZ1HD2AQdxSPOTYar9Og8W+5+lwak/eKwGumZ3obu8H7iwGpVgGDbb7WAL9FC
wzt6ZDyfsdHscKdSPONCQLHHtdUDx3vYTQP+23/FvkTDLG0KYJCb7kaB+nbBdv0a
T3OQajFtIw+BjKYZI5Wbb426wp6jA9iYD0135hVbkuyt41MhsFZBW9hQ3B48ndBH
3UPE5RPKzuVuIzKqqmR5/K5caRxjCQPlzFLAaHfGlS6SqD4QWIPCKs/763rFP6iJ
bSNXmQpeCV9NzF68wehmiYL3l07CjQkmwlTGr637rwaLWgT1Gi0dJUDvWCLDbe2S
/io018jIr2P+HUy65jHL2ap/zAQdZLbU88CHSBbmtdWvFQJJVjpO9gavDpv7LSO+
dxotTp0QzvHp+RFX1ALr9Osx20/IkCATcbNIA36cRW/3uop46sEJtjMi8PUf2Zqi
9Bp/qhv8qt2sR60F
=cWy2
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 6 Nov 2021 23:21
Re: bug#49006: MELPA importer uses the wrong source when called from CLI
(name . Xinglu Chen)(address . public@yoctocell.xyz)(address . 49006-done@debbugs.gnu.org)
87y261kjs4.fsf@gnu.org
Hi,

Xinglu Chen <public@yoctocell.xyz> skribis:

Toggle quote (3 lines)
> When the (guix import elpa) module has been compiled, the generated
> package definition uses ‘url-fetch’ to fetch the source.

[...]

Toggle quote (5 lines)
> However, if the (guix import elpa) module hasn’t been compiled, say I
> just add a dummy comment to it, then the generated package definition
> uses ‘git-fetch’ instead of ‘url-fetch’. Notice the messages emitted by
> Guile.

This is a miscompilation error that
d21353adea700b7f008d7a9f047d9f8b9c422cfb works around, presumably the

Thanks,
Ludo’.
Closed
?
Your comment

This issue is archived.

To comment on this conversation send email to 49006@debbugs.gnu.org