[bug#77212] gnu: rust: install stdlib manifest with original checksums

Message ID 87msdbhcfw.fsf@eugene.mail-host-address-is-not-set
State New
Headers
Series [bug#77212] gnu: rust: install stdlib manifest with original checksums |

Commit Message

Brennan Vincent March 23, 2025, 5:41 p.m. UTC
  * gnu/packages/rust.scm (rust): install stdlib manifest with original checksums

Change-Id: I1100ffe4ff67c8e2026e802fc3902ec218e2efee
---
 gnu/packages/rust.scm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)


base-commit: b54a9ca849f013300c633fb79d80bc754f6b28a2
prerequisite-patch-id: 2b36f42a4b79ce79d12ce58a03de81902054f2a1
  

Comments

Efraim Flashner March 25, 2025, 1:35 p.m. UTC | #1
Does it have to be the original checksums or will correct checksums
work?  Currently to save time we set all the checksums to
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 (an
empty file).

What changed in rust-analyzer 1.82 that made it change? Or was that part
of the error message?

On Sun, Mar 23, 2025 at 10:41:23AM -0700, Brennan Vincent wrote:
> * gnu/packages/rust.scm (rust): install stdlib manifest with original checksums
> 
> Change-Id: I1100ffe4ff67c8e2026e802fc3902ec218e2efee
> ---
>  gnu/packages/rust.scm | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
> index 3fd7fc3433..04d88f6a82 100644
> --- a/gnu/packages/rust.scm
> +++ b/gnu/packages/rust.scm
> @@ -1476,12 +1476,28 @@ (define-public rust
>                   (invoke "./x.py" "install" "clippy")
>                   (invoke "./x.py" "install" "rust-analyzer")
>                   (invoke "./x.py" "install" "rustfmt")))
> +             (add-before 'patch-cargo-checksums 'save-old-library-manifest
> +               (lambda _
> +                 (copy-file "library/Cargo.lock" ".old-library-manifest")))
>               (add-after 'install 'install-rust-src
>                 (lambda* (#:key outputs #:allow-other-keys)
>                   (let ((out (assoc-ref outputs "rust-src"))
>                         (dest "/lib/rustlib/src/rust"))
>                     (mkdir-p (string-append out dest))
>                     (copy-recursively "library" (string-append out dest "/library"))
> +                   ;; rust-analyzer needs the original checksums; otherwise,
> +                   ;; it fails to cargo manifest in the stdlib, and then
> +                   ;; analysis/inference involving stdlib structs doesn't work.
> +                   ;;
> +                   ;; For example, in the following trivial program:
> +                   ;; 
> +                   ;; fn main() {
> +                   ;;     let x = Vec::<usize>::new();
> +                   ;; }
> +                   ;;
> +                   ;; rust-analyzer since versino 1.82
> +                   ;; can't infer the type of x unless the following line is present.
> +                   (copy-file ".old-library-manifest" (string-append out dest "/library/Cargo.lock"))
>                     (copy-recursively "src" (string-append out dest "/src")))))
>               (add-before 'install 'remove-uninstall-script
>                 (lambda _
> 
> base-commit: b54a9ca849f013300c633fb79d80bc754f6b28a2
> prerequisite-patch-id: 2b36f42a4b79ce79d12ce58a03de81902054f2a1
> -- 
> 2.49.0
> 
>
  

Patch

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 3fd7fc3433..04d88f6a82 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -1476,12 +1476,28 @@  (define-public rust
                  (invoke "./x.py" "install" "clippy")
                  (invoke "./x.py" "install" "rust-analyzer")
                  (invoke "./x.py" "install" "rustfmt")))
+             (add-before 'patch-cargo-checksums 'save-old-library-manifest
+               (lambda _
+                 (copy-file "library/Cargo.lock" ".old-library-manifest")))
              (add-after 'install 'install-rust-src
                (lambda* (#:key outputs #:allow-other-keys)
                  (let ((out (assoc-ref outputs "rust-src"))
                        (dest "/lib/rustlib/src/rust"))
                    (mkdir-p (string-append out dest))
                    (copy-recursively "library" (string-append out dest "/library"))
+                   ;; rust-analyzer needs the original checksums; otherwise,
+                   ;; it fails to cargo manifest in the stdlib, and then
+                   ;; analysis/inference involving stdlib structs doesn't work.
+                   ;;
+                   ;; For example, in the following trivial program:
+                   ;; 
+                   ;; fn main() {
+                   ;;     let x = Vec::<usize>::new();
+                   ;; }
+                   ;;
+                   ;; rust-analyzer since versino 1.82
+                   ;; can't infer the type of x unless the following line is present.
+                   (copy-file ".old-library-manifest" (string-append out dest "/library/Cargo.lock"))
                    (copy-recursively "src" (string-append out dest "/src")))))
              (add-before 'install 'remove-uninstall-script
                (lambda _