diff mbox series

[bug#49280,v2,1/3] gnu: racket: Update to 8.2.

Message ID 20210719063143.788661-1-philip@philipmcgrath.com
State Accepted
Headers show
Series [bug#49280,v2,1/3] gnu: racket: Update to 8.2. | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Philip McGrath July 19, 2021, 6:31 a.m. UTC
* gnu/packages/racket.scm (racket-minimal, racket): Update to 8.2.
* gnu/packages/racket.scm (racket-minimal)[#:arguments]: Fix
patch-config.rktd-lib-search-dirs phase. When a config.rktd file
doesn't contain an entry for `lib-search-dirs`, the default is
equivalent to `'(#f)`, not `'()`.
---
 gnu/packages/racket.scm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Leo Prikler July 19, 2021, 7:46 p.m. UTC | #1
Am Montag, den 19.07.2021, 02:31 -0400 schrieb Philip McGrath:
> * gnu/packages/racket.scm (racket-minimal, racket): Update to 8.2.
> * gnu/packages/racket.scm (racket-minimal)[#:arguments]: Fix
> patch-config.rktd-lib-search-dirs phase. When a config.rktd file
> doesn't contain an entry for `lib-search-dirs`, the default is
> equivalent to `'(#f)`, not `'()`.
What is the point of this value?  Can we use a (sequence of) string(s)
in its stead?
> ---
>  gnu/packages/racket.scm | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm
> index 2d606071fe..6b2a011d51 100644
> --- a/gnu/packages/racket.scm
> +++ b/gnu/packages/racket.scm
> @@ -64,14 +64,14 @@
>  (define-public racket-minimal
>    (package
>      (name "racket-minimal")
> -    (version "8.1")            ; note: remember to also update
> racket!
> +    (version "8.2")            ; note: remember to also update
> racket!
>      (source
>       (origin
>         (method url-fetch)
>         (uri (map (lambda (base)
>                     (string-append base version "/racket-minimal-
> src.tgz"))
>                   %installer-mirrors))
> -       (sha256
> "04zzqybpxss50n1jrwwq98539gw0y0ygpw9civl2sq3s4ww7m8l3")
> +       (sha256
> "13qfg56w554vdj5iwa8lpacy83s7bzhhyr44pjns68mkhj69ring")
>         (patches (search-patches
>                   "racket-sh-via-rktio.patch"))))
>      (home-page "https://racket-lang.org")
> @@ -125,7 +125,7 @@
>                                    'lib-search-dirs
>                                    (lambda (dirs)
>                                      (append dirs extra-lib-search-
> dirs))
> -                                  null)
> +                                  '(#f))
>                                   #:exists 'truncate/replace
>                                   file)))
>                      "--"
> @@ -183,7 +183,7 @@ DrRacket IDE, are not included.")
>                   %installer-mirrors))
>         (sha256
>          (base32
> -         "0xdqwrwm604bbnr97h75dps2ixxz2svlw0fn0f674bn04dcfd60f"))))
> +         "10sgzsraxzxp1k2y2wvz8rcjwvhbcd6k72l9lyqr34yazlwfdz26"))))
>      (inputs
>       `(;; sqlite and libraries for `racket/draw' are needed to build
> the doc.
>         ("cairo" ,cairo)
Otherwise LGTM.
Philip McGrath July 19, 2021, 9:46 p.m. UTC | #2
Hi,

On 7/19/21 3:46 PM, Leo Prikler wrote:
> Am Montag, den 19.07.2021, 02:31 -0400 schrieb Philip McGrath:
>> * gnu/packages/racket.scm (racket-minimal, racket): Update to 8.2.
>> * gnu/packages/racket.scm (racket-minimal)[#:arguments]: Fix
>> patch-config.rktd-lib-search-dirs phase. When a config.rktd file
>> doesn't contain an entry for `lib-search-dirs`, the default is
>> equivalent to `'(#f)`, not `'()`.
> What is the point of this value?  Can we use a (sequence of) string(s)
> in its stead?

As you'd probably guess, `lib-search-dirs` and other `-search-dirs` 
"config.rktd" entries specify search paths. The `#f` value is used to 
specify the point at which the default search path should be spliced 
into the list: a configuration file can ignore the default altogether or 
exercise fine-grained control over the search order. Using `#f` also 
helps to maintain something closer to a single point of control, rather 
than hard-code the same string constants in several places.

Most importantly, the default value is not always a constant: for 
example, command-line flags and Racket parameters control whether 
user-specific paths are included.

(For `lib-search-dirs` in particular, it's also worth noting that these 
are Racket-specific search directories: it does not control the use of 
OS-level defaults for e.g. `dlopen`.)

The problems with omitting `#f` from `lib-search-dirs` were not very 
noticeable until the patch to start using layered and tethered 
installations. For a more obvious example, if `catalogs` is `'()`, `raco 
pkg` won't consult any package catalogs, whereas `'(#f)` will cause it 
to use the default catalogs.

The documentation for these configuration options is here: 
https://docs.racket-lang.org/raco/config-file.html#(idx._(gentag._70._(lib._scribblings%2Fraco%2Fraco..scrbl)))

(As of this writing, the docs on the website are still at 8.1---the 
whole package catalog is rebuilt after a new Racket release, which takes 
a little while to finish. You could alternatively apply this patch and 
run `lynx "file://"$(./pre-inst-env guix build 
racket)"/share/doc/racket/raco/config-file.html#(idx._(gentag._70._(lib._scribblings%2Fraco%2Fraco..scrbl)))"`.)


-Philip
Leo Prikler July 20, 2021, 9:40 a.m. UTC | #3
Am Montag, den 19.07.2021, 17:46 -0400 schrieb Philip McGrath:
> Hi,
> 
> On 7/19/21 3:46 PM, Leo Prikler wrote:
> > Am Montag, den 19.07.2021, 02:31 -0400 schrieb Philip McGrath:
> > > * gnu/packages/racket.scm (racket-minimal, racket): Update to
> > > 8.2.
> > > * gnu/packages/racket.scm (racket-minimal)[#:arguments]: Fix
> > > patch-config.rktd-lib-search-dirs phase. When a config.rktd file
> > > doesn't contain an entry for `lib-search-dirs`, the default is
> > > equivalent to `'(#f)`, not `'()`.
> > What is the point of this value?  Can we use a (sequence of)
> > string(s)
> > in its stead?
> 
> As you'd probably guess, `lib-search-dirs` and other `-search-dirs` 
> "config.rktd" entries specify search paths. The `#f` value is used
> to 
> specify the point at which the default search path should be spliced 
> into the list: a configuration file can ignore the default altogether
> or 
> exercise fine-grained control over the search order. Using `#f` also 
> helps to maintain something closer to a single point of control,
> rather 
> than hard-code the same string constants in several places.
Okay, but for this specific config, we could still splice #f ourselves
(particularly to also get full store paths), or can we not thanks to
the non-constant nature of #f?

> Most importantly, the default value is not always a constant: for 
> example, command-line flags and Racket parameters control whether 
> user-specific paths are included.
How exactly would this play out?  Would for example one version of #f
contain all of the user-installed packages in ~/.guix-profile whereas
the other would only contain racket's own path?

> (For `lib-search-dirs` in particular, it's also worth noting that
> these are Racket-specific search directories: it does not control the
> use of OS-level defaults for e.g. `dlopen`.)
Perhaps a confusing naming scheme, but okay.

> The problems with omitting `#f` from `lib-search-dirs` were not very 
> noticeable until the patch to start using layered and tethered 
> installations. For a more obvious example, if `catalogs` is `'()`,
> `raco pkg` won't consult any package catalogs, whereas `'(#f)` will
> cause it to use the default catalogs.
Okay, but `catalogs` is not `lib-search-dirs`, is it?  I'd assume
`'(#f)` is roughly equivalent to `'("default")` or `'("@spam@" "@ham@"
"@eggs@")` for some configure-time constant spam, ham and eggs.  Or
does the command-line flag variability apply to catalogs as well?

> The documentation for these configuration options is here: 
> https://docs.racket-lang.org/raco/config-file.html#(idx._(gentag._70._(lib._scribblings%2Fraco%2Fraco..scrbl)))
> 
> (As of this writing, the docs on the website are still at 8.1---the 
> whole package catalog is rebuilt after a new Racket release, which
> takes a little while to finish. You could alternatively apply this
> patch and run `lynx "file://"$(./pre-inst-env guix build 
> racket)"/share/doc/racket/raco/config-
> file.html#(idx._(gentag._70._(lib._scribblings%2Fraco%2Fraco..scrbl))
> )"`.)
I think more important than the semantics of the configuration file is
the purpose of this particular thing.  Is it a template from which
other stuff is derived?  In that case, we might want to use #f as you
did.  Is it instead used to build stuff in the racket package?  Then
we'd need to substitute it imo.

Regards
Philip McGrath July 25, 2021, 8:22 a.m. UTC | #4
On 7/20/21 5:40 AM, Leo Prikler wrote:
> Am Montag, den 19.07.2021, 17:46 -0400 schrieb Philip McGrath:
>> As you'd probably guess, `lib-search-dirs` and other `-search-dirs`
>> "config.rktd" entries specify search paths. The `#f` value is used
>> to
>> specify the point at which the default search path should be spliced
>> into the list: a configuration file can ignore the default altogether
>> or
>> exercise fine-grained control over the search order. Using `#f` also
>> helps to maintain something closer to a single point of control,
>> rather
>> than hard-code the same string constants in several places.
> Okay, but for this specific config, we could still splice #f ourselves
> (particularly to also get full store paths), or can we not thanks to
> the non-constant nature of #f?
> 
>> Most importantly, the default value is not always a constant: for
>> example, command-line flags and Racket parameters control whether
>> user-specific paths are included.
> How exactly would this play out?  Would for example one version of #f
> contain all of the user-installed packages in ~/.guix-profile whereas
> the other would only contain racket's own path?
> 
>> (For `lib-search-dirs` in particular, it's also worth noting that
>> these are Racket-specific search directories: it does not control the
>> use of OS-level defaults for e.g. `dlopen`.)
> Perhaps a confusing naming scheme, but okay.

The short answer is that I don't think including #f is causing any 
problems, whereas trying not to include it seems likely to cause a 
variety of problems.

I'll try to explain more clearly.

It might be more useful to look at the second patch in the series, which 
uses the "extend-layer.rkt" script to generate a "config.rkt" file for 
the `racket` package, and especially the third patch, which replaces 
this code completely for the `racket-minimal` package:

On 7/19/21 2:31 AM, Philip McGrath wrote:
> +         (add-before 'configure 'initialize-config.rktd
>              (lambda* (#:key inputs #:allow-other-keys)
> -             (chdir "src")
> +             (define (write-racket-hash alist)
> +               ;; inside must use dotted pair notation
> +               (display "#hash(")
> +               (for-each (match-lambda
> +                           ((k . v)
> +                            (format #t "(~s . ~s)" k v)))
> +                         alist)
> +               (display ")\n"))
> +             (mkdir-p "racket/etc")
> +             (with-output-to-file "racket/etc/config.rktd"
> +               (lambda ()
> +                 (write-racket-hash
> +                  `((lib-search-dirs
> +                     . (#f ,@(map (lambda (lib)
> +                                    (string-append (assoc-ref inputs 
lib)
> +                                                   "/lib"))
> +                                  '("openssl"
> +                                    "sqlite"))))
> +                    (catalogs
> +                     . (,(string-append
> +                          "https://download.racket-lang.org/releases/"
> +                          ,version
> +                          "/catalog/")
> +                        #f))))))
>                #t))

This code creates a template "config.rktd" file used in the build 
process: the distributed source tarballs contain such a template 
already, which is why we didn't need explicitly configure `catalogs` to 
add the release-pinned package catalog until this change. It is added 
before the `#f` so that the release catalog is checked before the 
default catalogs (which point to the latest sources). For 
`lib-search-dirs`, on the other hand, we want Racket-specific library 
paths to be tried first, and indeed for layers of a Racket installation 
to be searched in order, so `#f` is at the head of the list.

The Racket build process extends the template "config.rktd" file based 
on build options like the `--prefix` passed to `configure`. For example, 
it configures `lib-dir` to "lib/racket" within the store output 
directory. (It would be incorrect to set those values in the template 
"config.rktd" file because it is used in the build process before 
installation.)

The `#f` entry in `lib-search-dirs` is usually replaced by a 
user-specific path like "/home/philip/.local/share/racket/8.1/lib" and 
the installation-wide path specified by the `lib-dir` key, unless one or 
both are changed. Omitting the `#f` entry means that neither of paths 
are ever included. I don't know of any real-life circumstance in which 
one would want such a "config.rktd" file. In particular, missing `#f` 
entries creates problems for layered installations, which use these 
search paths to find earlier layers.

There are some other configuration possibilities we may want to explore 
as Guix's support for Racket packages improves, such as "addon" 
tethering and customizing the "installation name" or "build stamp". 
However, this patch series does not attempt to change how Guix's Racket 
packages work, other than correcting the error I introduced in 
<https://issues.guix.gnu.org/47180>. Racket installed via Guix has the 
same behavior in this respect as Racket installed via Debian or other 
package managers, and that's a way of using Racket I think Guix will 
want to continue to support.

-Philip
Leo Prikler July 25, 2021, 1:03 p.m. UTC | #5
Hi Philip,

Am Sonntag, den 25.07.2021, 04:22 -0400 schrieb Philip McGrath:
> The short answer is that I don't think including #f is causing any 
> problems, whereas trying not to include it seems likely to cause a 
> variety of problems.

That short explanation imo doesn't adequately summarize the long one. 
Rest assured, the long explanation gives us a good reason to use #f as
you did, it's just that the way to reach this point of understanding
appears a bit of a long one.

> I'll try to explain more clearly.
> 
> It might be more useful to look at the second patch in the series,
> which 
> uses the "extend-layer.rkt" script to generate a "config.rkt" file
> for 
> the `racket` package, and especially the third patch, which replaces 
> this code completely for the `racket-minimal` package:
> 
> On 7/19/21 2:31 AM, Philip McGrath wrote:
> > +         (add-before 'configure 'initialize-config.rktd
> >              (lambda* (#:key inputs #:allow-other-keys)
> > -             (chdir "src")
> > +             (define (write-racket-hash alist)
> > +               ;; inside must use dotted pair notation
> > +               (display "#hash(")
> > +               (for-each (match-lambda
> > +                           ((k . v)
> > +                            (format #t "(~s . ~s)" k v)))
> > +                         alist)
> > +               (display ")\n"))
> > +             (mkdir-p "racket/etc")
> > +             (with-output-to-file "racket/etc/config.rktd"
> > +               (lambda ()
> > +                 (write-racket-hash
> > +                  `((lib-search-dirs
> > +                     . (#f ,@(map (lambda (lib)
> > +                                    (string-append (assoc-ref
> > inputs 
> lib)
> > +                                                   "/lib"))
> > +                                  '("openssl"
> > +                                    "sqlite"))))
> > +                    (catalogs
> > +                     . (,(string-append
> > +                          "
> > https://download.racket-lang.org/releases/"
> > +                          ,version
> > +                          "/catalog/")
> > +                        #f))))))
> >                #t))
This is perhaps a somewhat noobish question, but why must we use dotted
pair notation here?  To me personally, reading '(a . (b c)) is
confusing as it could more clearly be written as '(a b c).  Is this a
Racket convention?

> This code creates a template "config.rktd" file used in the build 
> process: the distributed source tarballs contain such a template 
> already, which is why we didn't need explicitly configure `catalogs`
> to add the release-pinned package catalog until this change. It is
> added before the `#f` so that the release catalog is checked before
> the default catalogs (which point to the latest sources). For 
> `lib-search-dirs`, on the other hand, we want Racket-specific
> library paths to be tried first, and indeed for layers of a Racket
> installation to be searched in order, so `#f` is at the head of the
> list.
> 
> The Racket build process extends the template "config.rktd" file
> based on build options like the `--prefix` passed to `configure`. For
> example, it configures `lib-dir` to "lib/racket" within the store
> output directory. (It would be incorrect to set those values in the
> template "config.rktd" file because it is used in the build process
> before installation.)
> 
> The `#f` entry in `lib-search-dirs` is usually replaced by a 
> user-specific path like "/home/philip/.local/share/racket/8.1/lib"
> and the installation-wide path specified by the `lib-dir` key, unless
> one or both are changed. Omitting the `#f` entry means that neither
> of paths are ever included. I don't know of any real-life
> circumstance in which one would want such a "config.rktd" file. In
> particular, missing `#f` entries creates problems for layered
> installations, which use these search paths to find earlier layers.
> 
> There are some other configuration possibilities we may want to
> explore as Guix's support for Racket packages improves, such as
> "addon" tethering and customizing the "installation name" or "build
> stamp". However, this patch series does not attempt to change how
> Guix's Racket packages work, other than correcting the error I
> introduced in <https://issues.guix.gnu.org/47180>;. Racket installed
> via Guix has the same behavior in this respect as Racket installed
> via Debian or other package managers, and that's a way of using
> Racket I think Guix will want to continue to support.
To attempt a better summary: Specifying `#f' will allow Racket to
search for user-specific libraries etc. (in
$XDG_DATA_HOME/racket/$RACKET_VERSION) in addition to "system-specific" 
libraries stored in $HOME/.guix-profile, am I correct?

If so, then yes, doing that is absolutely fine (you could compare it to
how Emacs users can still install stuff via ELPA).

Regards,
Philip McGrath July 25, 2021, 6:04 p.m. UTC | #6
Hi,

On 7/25/21 9:03 AM, Leo Prikler wrote:
>> On 7/19/21 2:31 AM, Philip McGrath wrote:
>>> +         (add-before 'configure 'initialize-config.rktd
>>>               (lambda* (#:key inputs #:allow-other-keys)
>>> -             (chdir "src")
>>> +             (define (write-racket-hash alist)
>>> +               ;; inside must use dotted pair notation
>>> +               (display "#hash(")
>>> +               (for-each (match-lambda
>>> +                           ((k . v)
>>> +                            (format #t "(~s . ~s)" k v)))
>>> +                         alist)
>>> +               (display ")\n"))
>>> +             (mkdir-p "racket/etc")
>>> +             (with-output-to-file "racket/etc/config.rktd"
>>> +               (lambda ()
>>> +                 (write-racket-hash
>>> +                  `((lib-search-dirs
>>> +                     . (#f ,@(map (lambda (lib)
>>> +                                    (string-append (assoc-ref
>>> inputs
>> lib)
>>> +                                                   "/lib"))
>>> +                                  '("openssl"
>>> +                                    "sqlite"))))
>>> +                    (catalogs
>>> +                     . (,(string-append
>>> +                          "
>>> https://download.racket-lang.org/releases/"
>>> +                          ,version
>>> +                          "/catalog/")
>>> +                        #f))))))
>>>                 #t))
> This is perhaps a somewhat noobish question, but why must we use dotted
> pair notation here?  To me personally, reading '(a . (b c)) is
> confusing as it could more clearly be written as '(a b c).  Is this a
> Racket convention?

Yes, the Racket reader requires that hash table literals use dotted pair 
notation, e.g. #hash((a . (b c))(d . 2)). (Additionally, hand-written 
Racket would often use square brackets for the key–value pairs.) I think 
it's ultimately for historical reasons, but there are various 
subtleties: under `quasiquote`, for example, the value position can 
contain `unquote`, but the key position cannot.

Of course, that doesn't necessarily mean the Guile code must use dotted 
pairs, but, at least as a Racketeer, I found writing these s-expressions 
with a bit of a "Racket accent" helped me to remember that this code is 
generating Racket.

> To attempt a better summary: Specifying `#f' will allow Racket to
> search for user-specific libraries etc. (in
> $XDG_DATA_HOME/racket/$RACKET_VERSION) in addition to "system-specific"
> libraries stored in $HOME/.guix-profile, am I correct?
> 
> If so, then yes, doing that is absolutely fine (you could compare it to
> how Emacs users can still install stuff via ELPA).

Yes, that's a much better summary.

(Pedantically, the user-specific path could be different, depending on 
the configured installation name and other things.)

The other issue is that I believe *not* specifying `#f` for 
`racket-minimal` would break the build of `racket` starting in the 
second patch, when the main distribution becomes a layer chaining to 
`racket-minimal`. At least, it broke some examples of layered 
installation I tried, which is how I figured out I'd done the wrong 
thing in <https://issues.guix.gnu.org/47180>. If that were the only 
issue, there might be some other workaround, but it's worth bearing in 
mind, particularly because the problems caused by buggy "config.rktd" 
files can be subtle and easy to miss.

-Philip
Ludovic Courtès July 30, 2021, 11:05 p.m. UTC | #7
Hi,

Finally pushed this second series, minus ‘with-imported-modules’.

  db2c7e70ad gnu: racket-minimal: Bootstrap from C.
  65bad4d036 gnu: racket: Unbundle racket-minimal.
  1ae95ebcdd gnu: racket: Update to 8.2.

Thank you!

Ludo’.
diff mbox series

Patch

diff --git a/gnu/packages/racket.scm b/gnu/packages/racket.scm
index 2d606071fe..6b2a011d51 100644
--- a/gnu/packages/racket.scm
+++ b/gnu/packages/racket.scm
@@ -64,14 +64,14 @@ 
 (define-public racket-minimal
   (package
     (name "racket-minimal")
-    (version "8.1")            ; note: remember to also update racket!
+    (version "8.2")            ; note: remember to also update racket!
     (source
      (origin
        (method url-fetch)
        (uri (map (lambda (base)
                    (string-append base version "/racket-minimal-src.tgz"))
                  %installer-mirrors))
-       (sha256 "04zzqybpxss50n1jrwwq98539gw0y0ygpw9civl2sq3s4ww7m8l3")
+       (sha256 "13qfg56w554vdj5iwa8lpacy83s7bzhhyr44pjns68mkhj69ring")
        (patches (search-patches
                  "racket-sh-via-rktio.patch"))))
     (home-page "https://racket-lang.org")
@@ -125,7 +125,7 @@ 
                                   'lib-search-dirs
                                   (lambda (dirs)
                                     (append dirs extra-lib-search-dirs))
-                                  null)
+                                  '(#f))
                                  #:exists 'truncate/replace
                                  file)))
                     "--"
@@ -183,7 +183,7 @@  DrRacket IDE, are not included.")
                  %installer-mirrors))
        (sha256
         (base32
-         "0xdqwrwm604bbnr97h75dps2ixxz2svlw0fn0f674bn04dcfd60f"))))
+         "10sgzsraxzxp1k2y2wvz8rcjwvhbcd6k72l9lyqr34yazlwfdz26"))))
     (inputs
      `(;; sqlite and libraries for `racket/draw' are needed to build the doc.
        ("cairo" ,cairo)