about summary refs log tree commit diff
diff options
context:
space:
mode:
authorpjotrp <pjotr.public01@thebird.nl>2026-10-14 07:17:02 +0000
committerpjotrp <pjotr.public01@thebird.nl>2026-10-14 07:17:02 +0000
commit1df5c414e0ba4a9f6f541cbeccc60e7eb4e58bfa (patch)
tree5f7ad206c124dbf6a224744f1563de446238f82a
parent46671b5ce00c6ce216f7ea6dfcf35cd2bbf2fd3f (diff)
downloadguix-bioinformatics-1df5c414e0ba4a9f6f541cbeccc60e7eb4e58bfa.tar.gz
julia: aggregate the notebook load path into one directory
The wrapper listed every package's share/julia/loadpath separately, so
JULIA_LOAD_PATH grew to 332 entries / ~30 KB.  Pluto spawns its
workspace worker with that environment, and the exec then failed with
E2BIG ("Argument list too long"), so no notebook could run.  Build one
directory of symlinks to the packages and put that single entry on
JULIA_LOAD_PATH instead.
-rw-r--r--gn/packages/julia.scm50
1 files changed, 37 insertions, 13 deletions
diff --git a/gn/packages/julia.scm b/gn/packages/julia.scm
index 5f2f49a..6f83ade 100644
--- a/gn/packages/julia.scm
+++ b/gn/packages/julia.scm
@@ -2364,17 +2364,43 @@ the default backend.")
   (list julia-plutoui julia-distributions julia-roots julia-latexstrings
         julia-quadgk julia-prettytables julia-optim julia-plots))
 
+(define %pluto-notebook-julia-packages
+  ;; Every Julia package in the dependency closure of the notebook deps.
+  (let loop ((inputs (append-map package-transitive-inputs
+                                 %pluto-notebook-julia-deps))
+             (seen '())
+             (out '()))
+    (if (null? inputs)
+        (reverse out)
+        (let ((p (cadr (car inputs))))
+          (if (or (not (string-prefix? "julia-" (package-name p)))
+                  (member (package-name p) seen))
+              (loop (cdr inputs) seen out)
+              (loop (cdr inputs) (cons (package-name p) seen)
+                    (cons p out)))))))
+
 (define %pluto-notebook-loadpath
-  ;; share/julia/loadpath of every Julia package in the dependency closure
-  ;; of the above -- the shared environment the wrapper prepends to
-  ;; JULIA_LOAD_PATH.  Includes the packages' own dependencies.
-  (delete-duplicates
-   (filter-map (lambda (input)
-                 (let ((p (cadr input)))
-                   (and (string-prefix? "julia-" (package-name p))
-                        (file-append p "/share/julia/loadpath/"))))
-               (append-map package-transitive-inputs
-                           %pluto-notebook-julia-deps))))
+  ;; ONE directory of symlinks to each package's share/julia/loadpath, so
+  ;; JULIA_LOAD_PATH is a single entry.  Listing every package separately
+  ;; made it ~30 KB, and Pluto's workspace worker then failed to exec
+  ;; ("Argument list too long"/E2BIG).
+  (computed-file "pluto-notebook-loadpath"
+    (with-imported-modules '((guix build utils))
+      #~(begin
+          (use-modules (guix build utils) (ice-9 ftw))
+          (let ((out #$output))
+            (mkdir-p out)
+            (for-each
+             (lambda (srcdir)
+               (for-each
+                (lambda (name)
+                  (let ((dst (string-append out "/" name)))
+                    (unless (or (member name '("." ".."))
+                                (file-exists? dst))
+                      (symlink (string-append srcdir name) dst))))
+                (scandir srcdir)))
+             '#$(map (lambda (p) (file-append p "/share/julia/loadpath/"))
+                     %pluto-notebook-julia-packages)))))))
 
 (define-public pluto-notebook
   ;; The current Pluto notebook server, superseding julia-visuals.  It
@@ -2414,9 +2440,7 @@ the default backend.")
                        ;; prepended to the build-time JULIA_LOAD_PATH that
                        ;; carries the transitive deps of PlutoSliderServer.
                        (extra-load-path
-                        (apply string-append
-                               (map (lambda (dir) (string-append dir ":"))
-                                    (list #$@%pluto-notebook-loadpath))))
+                        (string-append #$%pluto-notebook-loadpath ":"))
                        (load-path (string-append extra-load-path
                                                  (getenv "JULIA_LOAD_PATH")))
                        (julia-update "import Pkg; Pkg.update()")