1#lang scribble/manual
2@(require scribble/bnf
3          scribble/core
4          "common.rkt"
5          (for-label pkg
6                     (except-in racket/base remove)
7                     setup/dirs
8                     setup/matching-platform))
9
10@(define @|Planet1| @|PLaneT|)
11
12@(define package-name-chars
13   @list{@litchar{a} through @litchar{z},
14         @litchar{A} through @litchar{Z},
15         @litchar{0} through @litchar{9},
16         @litchar{_}, and @litchar{-}})
17
18@(define raco-doc '(lib "scribblings/raco/raco.scrbl"))
19
20@(define (gtech s)
21   @tech[#:doc '(lib "scribblings/guide/guide.scrbl") s])
22
23@(define subcommand list)
24
25@; ----------------------------------------
26
27@title{Package Management in Racket}
28@author[@author+email["Jay McCarthy" "jay@racket-lang.org"]]
29
30The Racket package manager lets you install new libraries and
31collections, and the Racket package catalog  helps other Racket
32programmers find libraries that you make available.
33
34@table-of-contents[]
35
36@; ----------------------------------------
37
38@include-section["getting-started.scrbl"]
39
40@; ----------------------------------------
41
42@section{Package Concepts}
43
44A @deftech{package} is a set of modules in some number of
45@gtech{collections}. Modules installed using the Racket package
46manager are @racket[require]d like any other modules. For example, if
47the package @pkgname{tic-tac-toe} contains the module
48@filepath{matrix.rkt} in a @filepath{data} collection, then after
49@pkgname{tic-tac-toe} is installed,
50
51@racketblock[(require data/matrix)]
52
53imports the module. The package name is not mentioned with
54@racket[require], because packages are a way of managing library
55collections, not a way of referencing them. It is common, however, for
56a package to implement a collection whose name is the same as the
57package name---in which case a @racket[require] might appear to be
58referencing a @tech{package}, but it is actually referencing a
59@gtech{collection} provided by the @tech{package}.
60
61Each @tech{package} has associated @deftech{package metadata}:
62
63@itemlist[
64 @item{a @deftech{package name} --- a string made of the characters @|package-name-chars|.}
65 @item{a @deftech{checksum} --- a string that identifies different releases of a package. A
66                                package can be updated when its @tech{checksum} changes,
67                                whether or not its @tech{version} changes. The checksum normally
68                                can be computed as the SHA1 (see @racketmodname[openssl/sha1])
69                                of the package's content.}
70 @item{a @deftech{version} --- a string of the form @nonterm{maj}@litchar{.}@nonterm{min},
71                     @nonterm{maj}@litchar{.}@nonterm{min}@litchar{.}@nonterm{sub}, or
72                     @nonterm{maj}@litchar{.}@nonterm{min}@litchar{.}@nonterm{sub}@litchar{.}@nonterm{rel},
73                     @margin-note*{The constraints on version numbers are consistent with @racketmodname[version/utils]
74                     and force version numbers to be in a canonical form. For example, a would-be version
75                     string @racket["4.3.0"] must be written instead as @racket["4.3"], @racket["4.3.1.0"]
76                     must be written instead as @racket["4.3.1"], and @racket["4"] must be written as @racket["4.0"].}
77                     where @nonterm{maj}, @nonterm{min}, @nonterm{sub}, and @nonterm{rel} are
78                     all canonical decimal representations of natural numbers, @nonterm{rel} is not @litchar{0},
79                     @nonterm{sub} is not @litchar{0} unless
80                     @nonterm{rel} is supplied, @nonterm{min} has no more
81                     than two digits, and @nonterm{sub} and @nonterm{rel} have no more than
82                     three digits. A version is intended to reflect available features of
83                     a package, and should not be confused with different releases of
84                     a package as indicated by the @tech{checksum}.}
85 @item{a list of dependencies --- a list of packages to be installed simultaneously, optionally
86                                 with a lower bound on each package's @tech{version}.}
87]
88
89A @tech{package} is typically represented by a directory with the same
90name as the package. The @tech{checksum} is typically left implicit.
91The package directory can contain a file named @filepath{info.rkt}
92to declare other metadata (see @secref["metadata"]).
93
94@subsection[#:tag "concept:multi-collection"]{Single-collection and Multi-collection Packages}
95
96A @tech{package} can be a @tech{single-collection package} or a
97@tech{multi-collection package}:
98
99@itemlist[
100
101 @item{A @deftech{single-collection package}'s directory doubles as a
102       @gtech{collection} directory. By default, the package name also
103       doubles as the collection name, but if the package has an
104       @filepath{info.rkt} file that defines @racketidfont{collection} to a
105       string, then the string is used as the name of the package's
106       collection.}
107
108 @item{A @deftech{multi-collection package}'s directory contains
109       subdirectories, each of which is a @gtech{collection} that is
110       provided by the package (where the directory name is used as
111       the collection name). A @tech{multi-collection package} must
112       have an @filepath{info.rkt} file that defines
113       @racketidfont{collection} as @racket['multi].}
114
115]
116
117@subsection[#:tag "concept:source"]{Package Sources}
118
119A @deftech{package source} identifies a @tech{package}
120representation. Each package source type has a different way of
121storing the @tech{checksum} and providing the package content (usually
122with @tech{single-collection package} and @tech{multi-collection
123package} variants).
124
125The @tech{package source} types are:
126
127@itemlist[
128
129@; ----------------------------------------
130@item{a local file path naming an archive (as a plain path or @litchar{file://} URL)
131--- The name of the package
132is the basename of the archive file. The @tech{checksum} for archive
133@filepath{f.@nonterm{ext}} is given by the file @filepath{f.@nonterm{ext}.CHECKSUM}.
134The valid archive formats
135are (currently) @filepath{.zip}, @filepath{.tar}, @filepath{.tgz},
136@filepath{.tar.gz}, and
137@filepath{.plt}.
138Other than a @litchar{type} query, which affects inference as described below,
139any query or fragments parts of a @litchar{file://} URL are ignored.
140
141For example, @filepath{~/tic-tac-toe.zip} is an archive package
142source, and its @tech{checksum} would be inside
143@filepath{~/tic-tac-toe.zip.CHECKSUM}.
144
145An archive represents package content analogous to a directory, but if
146the archive's content is contained within a single top-level
147directory, then the directory's content (as opposed to the overall
148archive content) is used as the package content. The @filepath{.plt}
149format does not accommodate either an extra directory layer or a
150@tech{single-collection package} representation.
151
152A package source is inferred to refer to an archive file
153only when it has a suffix matching a valid archive format
154and when it starts with @litchar{file://} or does not start
155with alphabetic characters followed by @litchar{://}. In the
156case that the package source starts with @litchar{file://},
157it must be a URL without a @litchar{type} query or
158with a @litchar{type} query value of @litchar{file}.
159The inferred
160package name is the filename without its suffix.
161
162@history[#:changed "6.0.1.12"
163         @elem{Changed treatment of an archive that contains all
164               content within a top-level directory.}
165         #:changed "6.1.1.5"
166         @elem{Changed @litchar{file://} parsing to accept a general
167               URL, recognize a @litchar{type} query, and ignore any
168               other query or fragment.}]}
169
170@; ----------------------------------------
171@item{a local directory (as a plain path or @litchar{file://} URL)
172--- The name of the package is the name of the
173directory. The @tech{checksum} is not present.
174Other than a @litchar{type} query, which affects inference as described below,
175any query or fragments parts of a @litchar{file://} URL are ignored.
176
177For example,
178@filepath{~/tic-tac-toe/} is a directory package source.
179
180A package source is inferred to refer
181to a directory only when it does not have a file-archive suffix, does
182not match the grammar of a package name, and either starts with
183@litchar{file://} or does not start
184with alphabetic characters followed by @litchar{://}.  In the
185case that the package source starts with @litchar{file://},
186it must be a URL without a @litchar{type} query or
187with a @litchar{type} query value of @litchar{dir}, @litchar{link}, or
188@litchar{static-link}.
189The inferred package name is the directory name.
190
191When the package source is a @litchar{file://} URL with a
192@litchar{type} query value of @litchar{link} or @litchar{static-link},
193then the package is installed as directory link, the same as if
194@DFlag{link} or @DFlag{static-link} is supplied to
195@command-ref{install} or @command-ref{update}.
196
197@history[#:changed "6.1.1.5"
198         @elem{Changed @litchar{file://} parsing to accept a general
199               URL, recognize a @litchar{type} query, and ignore any
200               other query or fragment.}]}
201
202@item{a remote URL naming an archive --- This type follows the same
203rules as a local file path, but the archive and @tech{checksum} files are
204accessed via HTTP(S).
205
206For example,
207@filepath{http://game.com/tic-tac-toe.zip} is a remote URL package
208source whose @tech{checksum} is found at
209@filepath{http://game.com/tic-tac-toe.zip.CHECKSUM}.
210
211A package source is inferred to be a URL only when it
212starts with @litchar{http://} or @litchar{https://}, and it
213is inferred to be a file URL when the URL ends with a path element
214that could be inferred as a file archive.
215The inferred package name is from the URL's file name in the same
216way as for a file package source.}
217
218@; ----------------------------------------
219@item{a remote URL naming a directory --- The remote directory must
220contain a file named @filepath{MANIFEST} that lists all the contingent
221files. These are downloaded into a local directory and then the rules
222for local directory paths are followed. However, if the remote
223directory contains a file named @filepath{.CHECKSUM}, then it is used
224to determine the @tech{checksum}.
225
226For example,
227@filepath{http://game.com/tic-tac-toe/} is a directory URL package
228source whose @tech{checksum} is found at
229@filepath{http://game.com/tic-tac-toe/.CHECKSUM}.
230
231A package source is inferred to be a URL the same for a directory or
232file, and it is treated as a directory URL when it does not end with a
233path element that has an archive file suffix or a @filepath{.git}
234suffix. The inferred package name is the directory name.
235
236@history[#:changed "6.1.1.1" @elem{Added special-casing of the @filepath{.git} suffix.}]}
237
238@; ----------------------------------------
239@item{a remote URL naming a Git repository --- The format for such
240URLs is:
241
242@inset{@nonterm{scheme}@exec{://@nonterm{host}/}...@exec{/}@nonterm{repo}@;
243@optional{@exec{.git}}@optional{@exec{/}}@optional{@exec{?path=}@nonterm{path}}@;
244@optional{@exec{#}@nonterm{rev}}}
245
246where @nonterm{scheme} is @litchar{git}, @litchar{http},
247@litchar{https}, @litchar{git+http}, or @litchar{git+https},
248except when @nonterm{scheme} is @litchar{git} and
249@nonterm{host} is @litchar{github.com} (which is treated more specifically as a GitHub
250reference). The @nonterm{path} can contain multiple
251@litchar{/}-separated elements to form a path within the repository,
252and it defaults to the empty path. The @nonterm{rev} can be a branch,
253tag, or commit, and it defaults to using the default branch as reported
254by the server.
255
256@margin-note{Due to properties of the Git protocol, the archive might
257be accessed more efficiently when @nonterm{rev} refers to a branch or
258tag (even if it is written as a commit). In those cases, the content
259typically can be obtained without downloading irrelevant history.}
260
261For example, @filepath{http://bitbucket.org/game/tic-tac-toe#main}
262is a Git package source.
263
264A checkout of the repository at @nonterm{rev} provides the content of
265the package, and @nonterm{scheme} determines the protocol
266that is used to clone the repository. The package's @tech{checksum}
267is the hash identifying @nonterm{rev} if @nonterm{rev} is a branch or
268tag, otherwise @nonterm{rev} itself serves as the @tech{checksum}.
269
270A package source is inferred to be a Git reference when it starts with
271@litchar{git://} and the host is not @litchar{github.com}. A package
272source is also inferred to be a Git reference when it starts with
273@litchar{http://} or @litchar{https://} and the last non-empty path
274element ends in @litchar{.git}; a @litchar{.git} suffix is added if
275the source is otherwise specified to be a Git reference. Finally, a
276package source is inferred to be a Git reference when it starts with
277@litchar{git+https://} or @litchar{git+http://}, in which case no
278@litchar{.git} suffix in the path is needed to designate the source as
279a Git reference (and no @litchar{.git} suffix is implicitly added).
280The inferred package name is the last element of @nonterm{path} if it
281is non-empty, otherwise the inferred name is @nonterm{repo}.
282
283@history[#:changed "6.1.1.1" @elem{Added Git repository support.}
284         #:changed "8.0.0.13" @elem{Added @litchar{git+https://}
285                                    and @litchar{git+http://} support.}]}
286
287@; ----------------------------------------
288@item{a remote URL naming a GitHub repository --- The format for such
289URLs is the same as for a Git repository reference starting
290@litchar{git://}, but with @litchar{github.com} as the host:
291
292@inset{@exec{git://github.com/}@nonterm{user}@exec{/}@nonterm{repo}@;
293@optional{@exec{.git}}@optional{@exec{/}}@optional{@exec{?path=}@nonterm{path}}@;
294@optional{@exec{#}@nonterm{rev}}}
295
296For example, @filepath{git://github.com/game/tic-tac-toe#main}
297is a GitHub package source.
298
299@margin-note{A Github repository source that starts with
300@litchar{git://} obtains the same content that would be accessed if
301@litchar{github.com} were not treated specially. The special treatment
302is preserved for historical reasons, especially in combination
303with @envvar{PLT_USE_GITHUB_API}.}
304
305For backward compatibility, an older format is also supported:
306
307@inset{@exec{github://github.com/}@nonterm{user}@exec{/}@nonterm{repo}@;
308@exec{/}@nonterm{rev}@optional{@exec{/}@nonterm{path}}}
309
310The @exec{zip}-formatted archive for the repository (generated by
311GitHub for any commit) is used as a remote URL archive path.  The
312@tech{checksum} is the hash identifying @nonterm{rev} if @nonterm{rev}
313is a branch or tag, otherwise @nonterm{rev} itself serves as the
314@tech{checksum}.
315
316A package source is inferred to be a GitHub reference when it starts
317with @litchar{git://github.com/} or @litchar{github://}; a package
318source that is otherwise specified as a GitHub reference is
319automatically prefixed with @litchar{git://github.com/}. The inferred
320package name is the last element of @nonterm{path} if it is non-empty,
321otherwise the inferred name is @nonterm{repo}.
322
323If the @indexed-envvar{PLT_USE_GITHUB_API} environment variable is
324set, GitHub packages are obtained using the GitHub API protocol
325instead of using the Git protocol.
326
327@history[#:changed "6.3" @elem{Changed handling of
328                                      GitHub sources to use the Git
329                                      protocol by default.}]}
330
331@; ----------------------------------------
332@item{a @tech{package name} --- A @tech{package catalog} is
333consulted to determine the source and @tech{checksum} for the package.
334
335For
336example, @exec{tic-tac-toe} is a package name that can be used as a
337package source.
338
339A package source is inferred
340to be a package name when it fits the grammar of package names, which
341means that it has only the characters @|package-name-chars|.}
342
343]
344
345@subsection[#:tag "concept:catalog"]{Package Catalogs}
346
347A @deftech{package catalog} is a server or database that converts package
348names to other package sources. A @tech{package catalog} is identified by a string
349representing a URL, where a @litchar{http://} or @litchar{https://}
350URL indicates a remote server, and a @litchar{file://} URL indicates a
351local catalog in the form of an SQLite database or a directory tree.
352
353PLT supports two @tech{package catalog} servers that are enabled by
354default: @url{https://pkgs.racket-lang.org} for new packages and
355@url{http://planet-compats.racket-lang.org} for automatically
356generated packages for old @|PLaneT| packages. Anyone may host a
357@tech{package catalog}, and any file-serving HTTP host can act
358as a basic @tech{package catalog} server. See @secref["catalog-protocol"]
359for information on how package information is extracted from a catalog.
360
361@subsection[#:tag "concept:auto"]{Explicit vs@|._| Auto-Installation}
362
363When a package is installed, the original source of its installation
364is recorded, as well as whether the installation was an @tech{automatic installation}. An
365@deftech{automatic installation} is one that was installed because it
366was a dependency of some other package (as opposed to being installed
367explicitly by a user).
368
369@subsection[#:tag "concept:conflicts"]{Package Conflicts}
370
371Two packages are in @deftech{conflict} if they contain the same
372module. For example, if the package @pkgname{tic-tac-toe} contains the
373module file @filepath{data/matrix.rkt} and the package
374@pkgname{factory-optimize} contains the module file
375@filepath{data/matrix.rkt}, then @pkgname{tic-tac-toe} and
376@pkgname{factory-optimize} are in conflict.
377
378A package may also be in
379conflict with Racket itself, if it contains a module file that is part
380of the base Racket implementation. For example, any package that
381contains @filepath{racket/list.rkt} is in conflict with Racket.
382
383For the purposes of conflicts, a module is a file that ends in
384@filepath{.rkt}, @filepath{.ss}, or @filepath{.scrbl}, with the
385exception of files named @filepath{info.rkt}.
386
387@subsection[#:tag "concept:updates"]{Package Updates}
388
389Package A is a @deftech{package update} of Package B if (1) B is
390installed, (2) A and B have the same name, and (3) A's @tech{checksum} is
391different than B's. A @tech{single-collection package}
392can be a @tech{package update} of a @tech{multi-collection package}
393and vice versa.
394
395Note that a package @tech{version} is not taken
396into account when determining a @tech{package update}, although a change
397in a package's @tech{version} (in either direction)
398implies a change in the @tech{checksum} because the checksum is
399computed from the package source and the meta-data that specifies
400the version is part of the source.
401
402@subsection[#:tag "concept:scope"]{Package Scopes}
403
404A @deftech{package scope} determines the effect of package
405installations, updates, @|etc|, with respect to different users and
406Racket installations. The default @tech{package scope} can be
407configured, but it is normally @exec{user}, which makes actions
408specific to both the current user and the installation's name/version
409(in the sense of @racket[get-installation-name]). The
410@exec{installation} scope means that package operations affect
411all users of the Racket installation.
412
413A directory path can be used as a @tech{package scope}, in which case
414package operations affect the set of packages installations in the
415directory. An installation can be configured to include the directory
416in its search path for installed packages (see @secref["config-file"
417#:doc raco-doc]). When a directory path is used as a @tech{package
418scope}, operations such as dependency checking will use all paths in
419the configured search path starting with the one that is designed as a
420@tech{package scope}; if the designated path is not in the configured
421search path, then the dierctory by itself is used as the search path.
422
423Conflict checking disallows installation of the same or conflicting
424package in different scopes, but if such a configuration is forced,
425collections are found first in packages with @exec{user} @tech{package
426scope}. Search then proceeds in a configured order, where
427@exec{installation} @tech{package scope} typically precedes other
428directory @tech{package scopes}.
429
430The default package scope is determined by first checking the
431configuration at @racket['user] scope, and then checking for
432configuration in wider scopes like @racket['installation]. If the
433default package scope is not configured in any scope, then it defaults
434to @racket['user].
435
436@; ----------------------------------------
437
438@section[#:tag "cmdline"]{Using @exec{raco pkg}}
439
440The @exec{raco pkg} command provides package-management tools via
441sub-commands.
442
443@subcommand{@command/toc{install} @nonterm{option} ... @nonterm{pkg-source} ...
444 --- Installs the given @tech{package sources} (eliminating exact-duplicate @nonterm{pkg-source}s).
445     If a given @nonterm{pkg-source} is @seclink["concept:auto"]{auto-installed} (to satisfy some other package's
446     dependency), then it is promoted to explicitly installed.
447
448     If no @nonterm{pkg-source}s are supplied and the @DFlag{clone}
449     flag is not supplied, the current directory is installed as a
450     link. See the @DFlag{link} flag below for more details.
451
452     If no @nonterm{pkg-source}s are supplied and the @DFlag{clone}
453     flag is supplied, then the clone directory's name is used as the
454     only @nonterm{pkg-source} argument. See the @DFlag{clone} flag
455     below for more details.
456
457 The @exec{install} sub-command accepts
458 the following @nonterm{option}s:
459
460 @itemlist[
461
462 @item{@DFlag{type} @nonterm{type} or @Flag{t} @nonterm{type} --- Specifies an interpretation of the package source,
463       where @nonterm{type} is either @exec{file}, @exec{dir}, @exec{file-url}, @exec{dir-url}, @exec{git},
464       @exec{git-url}, @exec{github}, or @exec{name}. The difference between @exec{git} and @exec{git-url}
465       is that a @litchar{.git} suffix is added to a @litchar{http} or @litchar{https} URL for type @exec{git}, but
466       not for type @exec{git-url}. The type is normally inferred for each @nonterm{pkg-source}.}
467
468 @item{@DFlag{name} @nonterm{pkg} or @Flag{n} @nonterm{pkg} --- Specifies the name of the package,
469       which makes sense only when a single @nonterm{pkg-source} is provided. The name is normally
470       inferred for each @nonterm{pkg-source}.}
471
472 @item{@DFlag{checksum} @nonterm{checksum} --- Specifies a checksum for the package,
473       which normally makes sense only when a single @nonterm{pkg-source} is provided. The use of
474       @nonterm{checksum} depends on @nonterm{pkg-source}: for a Git or GitHub source, @nonterm{checksum} selects a checksum;
475       for a @tech{package name}, file path, or remote URL as a source, @nonterm{checksum} specifies an expected checksum;
476       for a directory path (including a remote directory URL without a @filepath{.CHECKSUM} file) as a source,
477       @nonterm{checksum} assigns a checksum.}
478
479 @item{@DFlag{deps} @nonterm{behavior} --- Selects the behavior for dependencies, where @nonterm{behavior} is one of
480  @itemlist[
481   @item{@exec{fail} --- Cancels the installation if dependencies are uninstalled or version requirements are unmet.
482        This behavior is the default for non-@tech{interactive mode}.}
483   @item{@exec{force} --- Installs the package(s) despite missing dependencies or version requirements.
484         Forcing an installation may leave package content in an inconsistent state. Implied packages
485         via @racketidfont{implies} or @racketidfont{update-implies} (see @secref["metadata"]) are not updated,
486         even if @DFlag{ignore-implies} is not specified.}
487   @item{@exec{search-ask} --- Looks for dependencies (when uninstalled) or updates (when version requirements are unmet)
488         via the configured @tech{package catalogs},
489         but asks the user whether packages should be installed or updated. This behavior is the default in @tech{interactive mode}.}
490   @item{@exec{search-auto} --- Like @exec{search-ask}, but does not ask for permission to install or update a dependency.}
491  ]
492
493         Unless @DFlag{ignore-implies} is specified, when a package is updated or installed, any package that
494         it implies via @racketidfont{implies} or @racketidfont{update-implies} (see @secref["metadata"]) is automatically
495         updated independent of @exec{fail}, @exec{search-ask}, or @exec{search-auto}, but implied dependencies
496         are not updated for @exec{force} behavior.}
497
498  @item{@DFlag{auto} --- Shorthand for @exec{@DFlag{deps} search-auto}.}
499
500  @item{@DFlag{update-deps} --- With @exec{search-ask} or @exec{search-auto} dependency behavior, checks
501        already-installed dependencies transitively for updates (even when
502        not forced by version requirements, @racketidfont{implies}, or @racketidfont{update-implies}), asking or automatically updating a
503        package when an update is available.
504
505        Unless @DFlag{ignore-implies} or @exec{@DFlag{deps} force} is specified, when a package is updated or installed,
506        any package that it implies @racketidfont{implies} or @racketidfont{update-implies} (see @secref["metadata"]) is
507        automatically updated independent of the behavior requested via @DFlag{update-deps}.}
508
509  @item{@DFlag{ignore-implies} --- Disables special treatment of dependencies that are listed
510        in @racketidfont{implies} or @racketidfont{update-implies} (see @secref["metadata"])
511        for an installed or updated package.}
512
513  @item{@DFlag{link} --- Implies @exec{--type dir}
514        and links the existing directory as an installed package, instead of copying the
515        directory's content to install. Directory @tech{package sources} are treated as links
516        by default, unless @DFlag{copy} is specified or the directory name was reported by
517        a catalog instead of specified directly.
518
519        The package is identified
520        as a @tech{single-collection package} or a @tech{multi-collection package} at the
521        time that it is installed, and that categorization does not change even if the @schemeidfont{collection}
522        definition in @filepath{info.rkt} is changed (i.e., the package must be removed and re-installed
523        for the change to take effect).}
524
525  @item{@DFlag{static-link} --- Implies @DFlag{link}, and also indicates that subdirectories
526        of the given directory will not change for each given directory that implements a
527        @tech{multi-collection package}.}
528
529  @item{@DFlag{copy} --- Disables default handling of directory @tech{package sources} as links,
530        and instead treats them like other sources: package content is copied to install.}
531
532  @item{@DFlag{clone} @nonterm{dir} --- A Git or GitHub @tech{package
533        source} is cloned as @nonterm{dir} and locally linked as the
534        package implementation. See also @secref["clone-link"].
535
536        If no @nonterm{pkg-source} is supplied, then the last path element
537        of @nonterm{dir} is used as a package name and used as a
538        @nonterm{pkg-source} argument.
539
540        Multiple @nonterm{pkg-source}
541        arguments make sense only if they all specify the same Git
542        repository (with different paths into the repository). The
543        @DFlag{clone} flag implies @DFlag{type} in the sense that each
544        @nonterm{pkg-source} must be either a Git or GitHub
545        @tech{package source} or a @tech{package name}, where a
546        @tech{package name} must be mapped by the @tech{package catalog} to a
547        Git or GitHub @tech{package source}.}
548
549  @item{@DFlag{source} --- Strips built elements of a package before installing, and implies @DFlag{copy}.
550                           See also @secref["strip"].}
551
552  @item{@DFlag{binary} --- Strips source elements of a package before installing, and implies @DFlag{copy}.
553                           See also @secref["strip"].}
554
555  @item{@DFlag{binary-lib} --- Strips source and documentation elements of a package before installing, and implies @DFlag{copy}.
556                           See also @secref["strip"].}
557
558 @item{@DFlag{scope} @nonterm{scope} --- Selects the @tech{package scope} for installation, where @nonterm{scope} is one of
559  @itemlist[
560   @item{@exec{installation} --- Install packages for all users of a Racket installation, rather than user-specific.}
561   @item{@exec{user} --- Install packages for the current user and current installation's name/version.}
562  ]
563  The default package scope is normally @exec{user}, but it can be configured with
564  @command-ref{config}@exec{ --set default-scope @nonterm{scope}}.
565  The default installation name is normally the Racket version, but it can be configured with
566  @command-ref{config}@exec{ --set name @nonterm{name}}.}
567 @item{@Flag{i} or @DFlag{installation} --- Shorthand for @exec{--scope installation}.}
568 @item{@Flag{u} or @DFlag{user} --- Shorthand for @exec{--scope user}.}
569 @item{@DFlag{scope-dir} @nonterm{dir} --- Select @nonterm{dir} as the @tech{package scope}.}
570
571 @item{@DFlag{catalog} @nonterm{catalog} --- Uses @nonterm{catalog}s instead of of the currently configured
572       @tech{package catalogs}. This flag can be provided multiple times. The catalogs are tried in the order provided.}
573
574  @item{@DFlag{skip-installed} --- Ignores any @nonterm{pkg-source}
575        whose name corresponds to an already-installed package, except for promoting @seclink["concept:auto"]{auto-installed}
576        packages to explicitly installed.}
577
578  @item{@DFlag{pkgs} --- Disables default installation of the current directory when no @nonterm{pkg-source}s
579        are supplied.}
580
581  @item{@DFlag{all-platforms} --- Considers package dependencies independent of the current platform
582        (instead of filtering dependencies to platforms other than the current one).}
583
584  @item{@DFlag{force} --- Ignores module conflicts, including conflicts due to installing a single
585        package in multiple scopes. Forcing an installation may leave package content in an
586        inconsistent state.}
587
588  @item{@DFlag{ignore-checksums} --- Ignores errors verifying package @tech{checksums} (unsafe).}
589
590  @item{@DFlag{strict-doc-conflicts} --- Refuses to install in user @tech{package scope} when
591        documentation-directory names would conflict with other packages. ``Conflicting''
592        documentation names are normally allowed for installation in user @tech{package scope},
593        but strict checking ensures that installation would succeed in other @tech{package scopes}.}
594
595  @item{@DFlag{no-cache} --- Disables use of the download cache.}
596
597  @item{@DFlag{multi-clone} @nonterm{mode} --- Specifies the handling
598   of packages that are from the same Git repository but are installed
599   with different clone-linking modes or different clone directories.
600   (See also @secref["git-workflow"].)
601   The following modes are available:
602   @itemlist[
603
604      @item{@exec{convert} --- Converts non-clone-linked packages (either newly or previously installed)
605                               to clone-linked packages, assuming that the packages that are clone-linked
606                               all use the same clone directory. If clone-linked packages currently use
607                               different clone directories, installation fails.}
608
609      @item{@exec{ask} --- In the case when packages can be converted, ask the user whether to convert
610                           or allow the different clone-linking modes or clone directories. If converting
611                           is not an option, the installation fails. This clone-handling mode is the default
612                           in @tech{interactive mode}.}
613
614      @item{@exec{fail} --- Reports an error and cancels the installation (the default in non-@tech{interactive mode}).}
615
616      @item{@exec{force} --- Allows packages to have different clone-linking modes or clone directories.}
617
618    ]}
619
620  @item{@DFlag{pull} @nonterm{mode} --- Specifies the way that commits
621   are merged to clone-linked packages (see @secref["git-workflow"])
622   on installation or update. The following modes are available:
623
624   @itemlist[
625
626      @item{@exec{ff-only} --- Commits are merged using @DFlag{ff-only}, and installation fails
627                               if the fast-forward merge fails.}
628
629      @item{@exec{try} --- Like @exec{ff-only}, but if the fast-forward fails, the repository checkout is
630                           left as-is, and installation continues.}
631
632      @item{@exec{rebase} --- Commits are merged using @exec{git rebase} instead of @exec{git merge}.}
633
634    ]}
635
636
637  @item{@DFlag{dry-run} --- Prevents changes to the current installation. All installation and update work is
638                            staged and checked, but the final installation step is skipped.}
639
640  @item{@DFlag{no-setup} --- Does not run @exec{raco setup} after installation. This behavior is also the case if the
641        environment variable @envvar{PLT_PKG_NOSETUP} is set to any non-empty value.}
642
643  @item{@DFlag{no-docs} or @Flag{D} --- Does not render documentation during setup after installation. This flag has no effect
644        with @DFlag{no-setup}.}
645
646  @item{@DFlag{recompile-only} ---Constrains @exec{raco setup} to at most recompile a module from
647        machine-independent form, reporting an error if compilation from source is needed. This
648        behavior is useful as a sanity check when installing built packages (to ensure that they
649        are properly built), but if a compilation error is reported, it will be after the package
650        is installed.}
651
652  @item{@DFlag{jobs} @nonterm{n} or @Flag{j} @nonterm{n} --- Installs and runs @exec{raco setup} with @nonterm{n} parallel jobs.}
653
654  @item{@DFlag{batch} --- Disables @deftech{interactive mode}, suppressing potential prompts for a user
655                          (e.g., about package dependencies or clone sharing).}
656
657  @item{@DFlag{no-trash} --- Refrains from moving updated or removed packages to a trash folder.}
658
659  @item{@DFlag{fail-fast} --- Breaks @exec{raco setup} as soon as any error is encountered.}
660 ]
661
662@history[#:changed "6.1.1.5" @elem{Added the @DFlag{batch}, @DFlag{clone}, and
663                                   @DFlag{multi-clone} flags.}
664         #:changed "6.1.1.6" @elem{Added the @DFlag{no-trash} flag, and changed
665                                   the @DFlag{deps} default to depend only on interactive mode.}
666         #:changed "6.1.1.8" @elem{Added the @DFlag{pull} flag.}
667         #:changed "6.4.0.14" @elem{Added the @DFlag{dry-run} flag.}
668         #:changed "7.2.0.8" @elem{Added the @DFlag{recompile-only} flag.}
669         #:changed "7.4.0.4" @elem{Added the @DFlag{no-docs}, @Flag{D} flags.}
670         #:changed "7.6.0.14" @elem{Allowed multiple @DFlag{catalog} flags.}
671         #:changed "8.0.0.13" @elem{Added @litchar{git-url} as a @DFlag{type} option.}]}
672
673
674@subcommand{@command/toc{update} @nonterm{option} ... @nonterm{pkg-source} ...
675--- Checks the specified package names for @tech{package updates} or
676replaces existing package installations with the given sources. If an
677update or replacement cannot be installed (e.g. it conflicts with
678another installed package), then this command fails without installing
679any of the @nonterm{pkg-source}s (or their dependencies).
680
681The treatment of a @nonterm{pkg-source} depends on the way that it parses:
682
683@itemlist[
684
685 @item{When a @nonterm{pkg-source} parses as a @tech{package name},
686       then the named package must be installed already, and it is
687       checked for updates. The @DFlag{lookup} and @DFlag{clone} flags
688       change this interpretation of @nonterm{pkg-source}.}
689
690 @item{If @nonterm{pkg-source} parses as a directory @tech{package
691       source}, and if the named package is installed as a link to a
692       @seclink["clone-link"]{Git repository clone}, then the clone is checked for
693       updates. The @DFlag{link}, @DFlag{static-link}, and
694       @DFlag{copy} flags change this interpretation of
695       @nonterm{pkg-source}.}
696
697 @item{Otherwise, @nonterm{pkg-source} specifies a @tech{package
698       source} to replace the current installation of the named package.}
699
700]
701
702If no @nonterm{pkg-source}, @DFlag{all} or @Flag{a} flag, or
703@DFlag{clone} flag is specified, and if the current directory is
704within a package, then the enclosing package is updated. If no
705@nonterm{pkg-source} is specified, but @DFlag{clone} is supplied, then
706the clone directory's name is used as the only @nonterm{pkg-source}
707argument.
708
709If a @tech{package scope} is not specified, the scope is inferred from
710the given @nonterm{pkg-source}s.
711
712 The @exec{update} sub-command accepts
713 the following @nonterm{option}s:
714
715 @itemlist[
716 @item{@DFlag{all} or @Flag{a} --- Updates all packages, if no packages are given in the argument list.}
717
718 @item{@DFlag{lookup} --- Causes a @tech{package name} as a
719       @nonterm{pkg-source} to be used as a replacement that is looked
720       up in a catalog, instead of the name of an installed package
721       that may have updates from its current source. (If the named
722       package was installed through a package name, then there's
723       effectively no difference, unless a different catalog is
724       used.)
725
726       By default, if @nonterm{pkg-source} refers to a package that is
727       currently linked as a @seclink["clone-link"]{Git repository
728       clone}, then replacing the installation with a
729       catalog-specified source has the effect of removing the clone
730       link. However, the @DFlag{lookup} flag can be combined with the
731       @DFlag{clone} flag (assuming that the catalog maps the package
732       to a Git repository) so that the resulting installation is a
733       linked repository clone.}
734
735 @item{@DFlag{type} @nonterm{type} or @Flag{t} @nonterm{type} --- Same as for @command-ref{install}.}
736 @item{@DFlag{name} @nonterm{pkg} or @Flag{n} @nonterm{pkg} --- Same as for @command-ref{install}.}
737 @item{@DFlag{checksum} @nonterm{checksum} --- Same as for @command-ref{install}.}
738 @item{@DFlag{deps} @nonterm{behavior} --- Same as for @command-ref{install}.}
739 @item{@DFlag{auto} --- Shorthand for @exec{@DFlag{deps} search-auto} plus @DFlag{update-deps}.}
740 @item{@DFlag{update-deps} --- Same as for @command-ref{install}, but
741       implied by @DFlag{auto} only for @command-ref{update}.}
742 @item{@DFlag{ignore-implies} --- Same as for @command-ref{install}.}
743 @item{@DFlag{link} --- Same as for @command-ref{install}, but a
744       directory package source is treated as a link by default only
745       when it does not correspond to a link or a Git repository
746       clone.}
747 @item{@DFlag{static-link} --- Same as for @command-ref{install}.}
748 @item{@DFlag{copy} --- Same as for @command-ref{install}.}
749 @item{@DFlag{clone} @nonterm{dir} --- Same as for
750    @command-ref{install}, except that a @nonterm{pkg-source} as a
751    @tech{package name} is treated as the name of an installed
752    package (unless @DFlag{lookup} is specified). In that case, the package must be currently installed
753    from a Git or GitHub source---possibly as directed by a
754    catalog---and that source is used for the clone (which replaces
755    the existing package installation).
756
757    To convert a clone-linked package to a normal installation, use
758    @command-ref{update} either with the @DFlag{lookup} flag or with
759    a replacement @tech{package source} that is not a package name.}
760@item{@DFlag{unclone} --- An alias for @DFlag{lookup}, which (absent
761    @DFlag{clone}) has the effect of replacing a link to a repository
762    clone with a normal package installation.}
763 @item{@DFlag{binary} --- Same as for @command-ref{install}.}
764 @item{@DFlag{source} --- Same as for @command-ref{install}.}
765 @item{@DFlag{scope} @nonterm{scope} --- Selects a @tech{package scope}, the same as for @command-ref{install}.}
766 @item{@Flag{i} or @DFlag{installation} --- Shorthand for @exec{--scope installation}.}
767 @item{@Flag{u} or @DFlag{user} --- Shorthand for @exec{--scope user}.}
768 @item{@DFlag{scope-dir} @nonterm{dir} --- Selects @nonterm{dir} as the @tech{package scope}, the same as for @command-ref{install}.}
769 @item{@DFlag{catalog} @nonterm{catalog} --- Same as for @command-ref{install}.}
770 @item{@DFlag{skip-uninstalled} --- Ignores any @nonterm{pkg-source} that does not correspond to an installed package.}
771 @item{@DFlag{all-platforms} --- Same as for @command-ref{install}.}
772 @item{@DFlag{force} --- Same as for @command-ref{install}.}
773 @item{@DFlag{ignore-checksums} --- Same as for @command-ref{install}.}
774 @item{@DFlag{strict-doc-conflicts} --- Same as for @command-ref{install}.}
775 @item{@DFlag{no-cache} --- Same as for @command-ref{install}.}
776
777 @item{@DFlag{multi-clone} @nonterm{mode} --- Same as for @command-ref{install}, except that when
778       @DFlag{lookup} is specified and @DFlag{clone} is not specified, then conversion goes from
779       clone to non-clone linking---but only for sharing differences implied by the immediate
780       command-line arguments compared against existing package installations.}
781
782 @item{@DFlag{pull} @nonterm{mode} --- Same as for @command-ref{install}}
783
784 @item{@DFlag{dry-run} --- Same as for @command-ref{install}.}
785 @item{@DFlag{no-setup} --- Same as for @command-ref{install}.}
786 @item{@DFlag{no-docs} or @Flag{D} --- Same as for @command-ref{install}.}
787 @item{@DFlag{recompile-only} --- Same as for @command-ref{install}.}
788 @item{@DFlag{jobs} @nonterm{n} or @Flag{j} @nonterm{n} --- Same as for @command-ref{install}.}
789 @item{@DFlag{batch} --- Same as for @command-ref{install}.}
790 @item{@DFlag{no-trash} --- Same as for @command-ref{install}.}
791 ]
792
793@history[#:changed "6.1.1.5" @elem{Added the @DFlag{batch}, @DFlag{clone}, and
794                                   @DFlag{multi-clone} flags, and
795                                   added update of enclosing package
796                                   when no arguments are provided.}
797         #:changed "6.1.1.6" @elem{Added the @DFlag{no-trash} flag, and changed
798                                   the @DFlag{deps} default to depend only on interactive mode.}
799         #:changed "6.1.1.8" @elem{Added the @DFlag{skip-uninstalled} and @DFlag{pull} flags.}
800         #:changed "6.4.0.14" @elem{Added the @DFlag{dry-run} flag.}
801         #:changed "6.90.0.27" @elem{Added the @DFlag{unclone} flag.}
802         #:changed "7.2.0.8" @elem{Added the @DFlag{recompile-only} flag.}
803         #:changed "7.4.0.4" @elem{Added the @DFlag{no-docs}, @Flag{D} flags.}
804         #:changed "7.6.0.14" @elem{Allowed multiple @DFlag{catalog} flags.}]}
805
806@subcommand{@command/toc{remove} @nonterm{option} ... @nonterm{pkg} ...
807--- Attempts to remove the given packages. By default, if a package is the dependency
808of another package that is not listed, this command fails without
809removing any of the @nonterm{pkg}s.
810
811If a @tech{package scope} is not specified, the scope is inferred from
812the given @nonterm{pkg}s.
813
814 The @exec{remove} sub-command accepts
815 the following @nonterm{option}s:
816
817 @itemlist[
818 @item{@DFlag{demote} --- ``Removes'' explicitly installed packages by demoting them to @seclink["concept:auto"]{auto-installed}
819                            (leaving auto-installed packages as such). Combined with @DFlag{auto}, removes
820                            packages for which there are no dependencies.}
821 @item{@DFlag{force} --- Ignores dependencies when removing packages.}
822 @item{@DFlag{auto} --- In addition to removing each @nonterm{pkg},
823                        removes @seclink["concept:auto"]{auto-installed} packages (i.e., installed by the @exec{search-auto} or @exec{search-ask}
824                        dependency behavior, or demoted via @DFlag{demote}) that are no longer required by any
825                        explicitly installed package.}
826 @item{@DFlag{scope} @nonterm{scope} --- Selects a @tech{package scope}, the same as for @command-ref{install}.}
827 @item{@Flag{i} or @DFlag{installation} --- Shorthand for @exec{--scope installation}.}
828 @item{@Flag{u} or @DFlag{user} --- Shorthand for @exec{--scope user}.}
829 @item{@DFlag{scope-dir} @nonterm{dir} --- Selects @nonterm{dir} as the @tech{package scope}, the same as for @command-ref{install}.}
830 @item{@DFlag{dry-run} --- Same as for @command-ref{install}.}
831 @item{@DFlag{no-setup} --- Same as for @command-ref{install}.}
832 @item{@DFlag{no-docs} or @Flag{D} --- Same as for @command-ref{install}.}
833 @item{@DFlag{recompile-only} --- Same as for @command-ref{install}.}
834 @item{@DFlag{jobs} @nonterm{n} or @Flag{j} @nonterm{n} --- Same as for @command-ref{install}.}
835 @item{@DFlag{batch} --- Same as for @command-ref{install}.}
836 @item{@DFlag{no-trash} --- Same as for @command-ref{install}.}
837 ]
838
839@history[#:changed "6.1.1.5" @elem{Added the @DFlag{batch} flag.}
840         #:changed "6.1.1.6" @elem{Added the @DFlag{no-trash} flag.}
841         #:changed "6.4.0.14" @elem{Added the @DFlag{dry-run} flag.}
842         #:changed "7.2.0.8" @elem{Added the @DFlag{recompile-only} flag.}
843         #:changed "7.4.0.4" @elem{Added the @DFlag{no-docs}, @Flag{D} flags.}]}
844
845
846@subcommand{@command/toc{new} @nonterm{pkg} ---
847Populates a directory with the stubs for a new package, where
848@nonterm{pkg} is the name of the new package.
849If @nonterm{pkg} already exists as a directory in the current directory, no new
850package is created.
851
852@history[#:added "6.1.1.5"]}
853
854
855@subcommand{@command/toc{show} @nonterm{option} ... @nonterm{pkg} ... --- Prints information about currently installed packages.
856
857 If @nonterm{pkg}s are specified, then only those packages are shown.
858 By default, packages are shown for all @tech{package scopes}, but only for packages
859 not marked as @seclink["concept:auto"]{auto-installed}. If a package is
860 explicitly specified, it is shown even if it is marked as
861 auto-installed. Unless @Flag{l} or @DFlag{long} is specified,
862 the output is roughly constrained to 80 columns or the number of columns specified by the @envvar{COLUMNS}
863 environment variable. Unless @DFlag{full-checksum} is specified,
864 checksums are abbreviated to 8 characters.
865
866 The @exec{show} sub-command accepts
867 the following @nonterm{option}s:
868
869 @itemlist[
870
871 @item{@Flag{a} or @DFlag{all} --- Includes @seclink["concept:auto"]{auto-installed} packages in the listing.}
872 @item{@Flag{l} or @DFlag{long} --- Shows complete columns, instead of abbreviating to a width,
873                                    and use a more regular (but less
874 human-readable) format for some columns.}
875 @item{@DFlag{rx} --- Treats the @nonterm{pkg}s as regular expressions
876 for displaying specific packages.}
877 @item{@DFlag{full-checksum} --- Prints the full instead of the
878 abbreviated checksum.}
879 @item{@Flag{d} or @DFlag{dir} --- Adds a column in the output to show the directory where the package is installed.}
880
881 @item{@DFlag{scope} @nonterm{scope} --- Shows only packages in @nonterm{scope}, which is one of
882  @itemlist[
883   @item{@exec{installation} --- Show only installation-wide packages.}
884   @item{@exec{user} --- Show only user-specific packages for the current installation's name/version
885            or the name/version specified with @DFlag{version} or @Flag{v}.}
886  ]
887  The default is to show packages for all @tech{package scopes}.}
888 @item{@Flag{i} or @DFlag{installation} --- Shorthand for @exec{--scope installation}.}
889 @item{@Flag{u} or @DFlag{user} --- Shorthand for @exec{--scope user}.}
890 @item{@DFlag{scope-dir} @nonterm{dir} --- Shows only packages installed in @nonterm{dir}.}
891 @item{@DFlag{version} @nonterm{vers} or @Flag{v} @nonterm{vers} --- Show only user-specific packages for
892       the installation name/version @nonterm{vers}.}
893 ]
894
895@history[#:changed "6.1.1.5" @elem{Added @Flag{l}/@DFlag{long} and
896@envvar{COLUMNS} support.}
897         #:changed "6.1.1.6" @elem{Added explicit @nonterm{pkg}s and
898         @DFlag{rx} and @DFlag{full-sha}.}]}
899
900@subcommand{@command/toc{migrate} @nonterm{option} ... @nonterm{from-version}
901 --- Installs packages that were previously installed in @exec{user}
902     @tech{package scope} for @nonterm{from-version}, where
903     @nonterm{from-version} is an installation name/version.
904
905 The @exec{migrate} sub-command accepts
906 the following @nonterm{option}s:
907 @itemlist[
908
909 @item{@DFlag{deps} @nonterm{behavior} --- Same as for @command-ref{install}, except that @exec{search-auto} is
910       the default.}
911
912  @item{@DFlag{source} --- Same as for @command-ref{install}.}
913  @item{@DFlag{binary} --- Same as for @command-ref{install}.}
914  @item{@DFlag{binary-lib} --- Same as for @command-ref{install}.}
915  @item{@DFlag{scope} @nonterm{scope} --- Same as for @command-ref{install}.}
916  @item{@Flag{i} or @DFlag{installation} --- Shorthand for @exec{--scope installation}.}
917  @item{@Flag{u} or @DFlag{user} --- Shorthand for @exec{--scope user}.}
918  @item{@DFlag{scope-dir} @nonterm{dir} --- Select @nonterm{dir} as the @tech{package scope}.}
919  @item{@DFlag{catalog} @nonterm{catalog} --- Same as for @command-ref{install}.}
920  @item{@DFlag{all-platforms} --- Same as for @command-ref{install}.}
921  @item{@DFlag{force} --- Same as for @command-ref{install}.}
922  @item{@DFlag{ignore-checksums} --- Same as for @command-ref{install}.}
923  @item{@DFlag{strict-doc-conflicts} --- Same as for @command-ref{install}.}
924  @item{@DFlag{no-cache} --- Same as for @command-ref{install}.}
925  @item{@DFlag{dry-run} --- Same as for @command-ref{install}.}
926  @item{@DFlag{no-setup} --- Same as for @command-ref{install}.}
927  @item{@DFlag{no-docs} or @Flag{D} --- Same as for @command-ref{install}.}
928  @item{@DFlag{recompile-only} --- Same as for @command-ref{install}.}
929  @item{@DFlag{jobs} @nonterm{n} or @Flag{j} @nonterm{n} --- Same as for @command-ref{install}.}
930 ]
931
932@history[#:changed "6.4.0.14" @elem{Added the @DFlag{dry-run} flag.}
933         #:changed "7.2.0.8" @elem{Added the @DFlag{recompile-only} flag.}
934         #:changed "7.4.0.4" @elem{Added the @DFlag{no-docs}, @Flag{D} flags.}
935         #:changed "7.6.0.14" @elem{Allowed multiple @DFlag{catalog} flags.}]}
936
937@subcommand{@command/toc{create} @nonterm{option} ... @nonterm{directory-or-package}
938--- Bundles a package into an archive. Bundling
939    is not needed for a package that is provided directly from a
940    Git repository or other non-archive formats. The @exec{create}
941    sub-command can create an archive from a directory (the default) or
942    from an installed package. It can also adjust the archive's content
943    to include only sources, only compiled bytecode and rendered documentation,
944    or both---but packages are
945    normally provided as source and converted to binary form by an
946    automatic service, instead of by a package author.
947
948 The @exec{create} sub-command accepts
949 the following @nonterm{option}s:
950
951 @itemlist[
952 @item{@DFlag{from-dir} --- Treats @nonterm{directory-or-package} as a directory path; this is the default mode.}
953 @item{@DFlag{from-install} --- Treats @nonterm{directory-or-package} as the name of an installed package
954       (instead of a directory).}
955 @item{@DFlag{format} @nonterm{format} --- Specifies the archive format.
956      The allowed @nonterm{format}s are: @exec{zip} (the default), @exec{tgz}, and @exec{plt}.
957      This option must be specified if @DFlag{manifest} is not present.}
958 @item{@DFlag{manifest} --- Creates a manifest file for a directory, rather than an archive.}
959 @item{@DFlag{as-is} --- Bundles all content of the package directory as is, with no filtering
960       of sources, compiled files, or repository elements.}
961 @item{@DFlag{source} --- Bundles only sources in the package directory; see @secref["strip"].}
962 @item{@DFlag{binary} --- Bundles compiled bytecode and rendered
963       documentation in the package directory; see @secref["strip"].}
964 @item{@DFlag{binary-lib} --- Bundles compiled bytecode only in the package directory; see @secref["strip"].}
965 @item{@DFlag{built} --- Bundles compiled sources, bytecode, and rendered
966       documentation in the package directory, filtering repository elements; see @secref["strip"].}
967  @item{@DFlag{dest} @nonterm{dest-dir} --- Writes generated bundles to @nonterm{dest-dir}.}
968  ]
969}
970
971@subcommand{@command/toc{config} @nonterm{option} ... @optional[@nonterm{key}] @nonterm{val} ... ---
972Views and modifies the configuration of the package manager. If @nonterm{key} is not provided,
973the values for all recognized keys are shown. The @nonterm{val} arguments are allowed
974only when @DFlag{set} is used, in which case the @nonterm{val}s are used as the new values
975for @nonterm{key}.
976
977 The @exec{config} sub-command accepts
978 with the following @nonterm{option}s:
979
980 @itemlist[
981 @item{@DFlag{set} --- Sets an option, rather than printing it.}
982 @item{@DFlag{scope} @nonterm{scope} --- Selects a @tech{package scope}, the same as for @command-ref{install}.
983                                         A configuration value set at @exec{installation} scope serves
984                                         as the default value at @exec{user} scope.}
985 @item{@Flag{i} or @DFlag{installation} --- Shorthand for @exec{--scope installation}.}
986 @item{@Flag{u} or @DFlag{user} --- Shorthand for @exec{--scope user}.}
987 @item{@DFlag{scope-dir} @nonterm{dir} --- Same as for @command-ref{install}.}
988 ]
989
990 The valid @nonterm{key}s and corresponding @nonterm{val}s are:
991 @itemlist[
992  @item{@exec{name} --- A string for the installation's name, which is used by @exec{user}
993        @tech{package scope} and defaults to the Racket version.}
994  @item{@exec{catalogs} --- A list of URLs for @tech{package catalogs}. An empty-string
995        @nonterm{val} is replaced by the sequence of catalogs for the default configuration.
996        A @nonterm{val} that does not start with alphabetic characters followed by @litchar{://}
997        is treated as a path relative to the configuration directory (as
998        reported by @racket[find-config-dir]).}
999  @item{@exec{default-scope} --- Either @exec{installation} or @exec{user}.
1000        The value of this key at @exec{user} scope (possibly defaulting from
1001        @exec{installation} scope) is
1002        the default @tech{package scope} for @exec{raco pkg} commands for which
1003        a scope is not inferred from a given set of package names
1004        (even for @command{config}, which is consistent but potentially confusing).}
1005  @item{@exec{download-cache-dir} --- A directory that holds copies of
1006        downloaded packages, used to avoid re-downloading if the
1007        same URL and checksum combination is requested again. The default cache directory is
1008        user-specific (but not specific to a Racket version or
1009        installation name).}
1010  @item{@exec{download-cache-max-files} --- A limit on the number of files to
1011        be kept in the download cache directory.}
1012  @item{@exec{download-cache-max-bytes} --- A limit on the total size of files
1013        that are kept in the download cache directory.}
1014  @item{@exec{doc-open-url} --- A URL to use in place of a local
1015        filesystem path for viewing (or at least searching)
1016        documentation; an empty string, which is the default, disables
1017        the URL so that the local filesystem is used. This key can be
1018        set only in @exec{installation} scope.}
1019  @item{@exec{git-checkout-credentials} --- A list that starts with a format
1020        specification (currently only @racket['basic] is supported), followed
1021        by git credentials in the form @nonterm{username}@litchar{:}@nonterm{password}
1022        that are tried when downloading packages with git sources using the
1023        HTTP or HTTPS protocols. The credentials are currently stored
1024        @bold{unencrypted} on the filesystem.}
1025  @item{@exec{trash-max-packages} --- A limit on the number of package implementations
1026        that are kept in a trash folder when the package is removed or updated.}
1027  @item{@exec{trash-max-seconds} --- A limit on the time since a package is removed or
1028        updated that its implementation is kept in the trash folder. Package implementations are
1029        removed from a trash folder only when another package is potentially added
1030        to the trash folder or @command-ref{empty-trash} is used.}
1031  @item{@exec{network-retries} --- The number of times to retry a network communication that
1032        fails due to a connection error.}
1033 ]
1034
1035@history[#:changed "6.1.1.6" @elem{Added @exec{trash-max-packages} and @exec{trash-max-seconds}.}
1036         #:changed "6.3" @elem{Added @exec{network-retries}.}
1037         #:changed "6.6.0.5" @elem{Added @exec{git-checkout-credentials}.}]}
1038
1039
1040@subcommand{@command/toc{catalog-show} @nonterm{option} ... @nonterm{package-name} ...
1041--- Consults @tech{package catalogs} for a package (that is not necessarily installed)
1042    and displays the catalog's information for the package, such as its source URL and
1043    a checksum.
1044
1045 The @exec{catalog-show} sub-command accepts
1046 the following @nonterm{option}s:
1047
1048 @itemlist[
1049 @item{@DFlag{all} --- Shows information for all available packages. When using this flag,
1050                      supply no @nonterm{package-name}s.}
1051 @item{@DFlag{only-names} --- Shows only package names. This option is mainly useful with
1052                              @DFlag{all}, but when a @nonterm{package-name} is provided,
1053                              catalogs are consulted to ensure that he package is available.}
1054 @item{@DFlag{modules} --- Shows the modules that are implemented by a package.}
1055 @item{@DFlag{catalog} @nonterm{catalog} --- Queries @nonterm{catalog}s instead of the currently configured
1056       @tech{package catalogs}. This flag can be provided multiple times. The catalogs are tried in the order provided.}
1057 @item{@DFlag{version} @nonterm{version} or @Flag{v} @nonterm{version} --- Queries catalogs
1058       for a result specific to @nonterm{version},
1059       instead of the installation's Racket version.}
1060 ]
1061@history[#:changed "7.6.0.14" @elem{Allowed multiple @DFlag{catalog} flags.}]
1062}
1063
1064@subcommand{@command/toc{catalog-copy} @nonterm{option} ... @nonterm{src-catalog} ... @nonterm{dest-catalog}
1065--- Copies information from the @tech{package catalog} named by @nonterm{src-catalog}s
1066    to a local database or directory @nonterm{dest-catalog},
1067    which can be used as a new @tech{package catalog}.
1068
1069    The @nonterm{src-catalog}s can be remote or local, while @nonterm{dest-catalog} must be local
1070    (i.e., a directory path or a SQLite database path, as inferred from the path).
1071    If a @nonterm{src-catalog} or @nonterm{dest-catalog} does not start with a URL scheme, it is
1072    treated as a filesystem path. Information from multiple @nonterm{src-catalog}s is merged,
1073    with information from earlier @nonterm{src-catalog}s taking precedence over later
1074    @nonterm{src-catalog}s.
1075
1076    The @exec{catalog-copy} sub-command accepts
1077    the following @nonterm{option}s:
1078
1079 @itemlist[
1080 @item{@DFlag{from-config} --- Adds the currently configured
1081       @tech{package catalogs} to the end of the @nonterm{src-catalog}s list.}
1082 @item{@DFlag{force} --- Replaces @nonterm{dest-catalog} if it exists already.}
1083 @item{@DFlag{merge} --- Adds to @nonterm{dest-catalog} if it exists already. By default,
1084                         information already in @nonterm{dest-catalog} takes precedence
1085                         over new information.}
1086 @item{@DFlag{override} --- Changes merging so that new information takes precedence
1087                         over information already in @nonterm{dest-catalog}.}
1088 @item{@DFlag{relative} --- Writes package sources to @nonterm{dest-catalog} in relative-path form,
1089                            when possible.}
1090 @item{@DFlag{version} @nonterm{version} or @Flag{v} @nonterm{version} --- Copies catalog
1091       results specific to @nonterm{version}
1092       (for catalogs that make a distinction), instead of the installation's Racket version.}
1093 ]
1094}
1095
1096@subcommand{@command/toc{catalog-archive} @nonterm{option} ... @nonterm{dest-dir} @nonterm{src-catalog} ...
1097--- Copies information from the @tech{package catalog} named by @nonterm{src-catalog}s
1098    to a @filepath{catalog} directory catalog in @nonterm{dest-dir}, and also copies
1099    all package sources to a @filepath{pkgs} directory in @nonterm{dest-dir}.
1100
1101    Packages sources are downloaded and repacked as needed, so that
1102    all packages are written to the @filepath{pkgs} directory as
1103    @filepath{.zip} archives. This conversion may change the checksum
1104    on each archived package.
1105
1106    The @exec{catalog-archive} sub-command accepts
1107    the following @nonterm{option}s:
1108
1109 @itemlist[
1110 @item{@DFlag{from-config} --- Adds the currently configured
1111       @tech{package catalogs} to the end of the @nonterm{src-catalog}s list.}
1112 @item{@DFlag{state} @nonterm{state-database} --- To enable incremental
1113       updating, reads and writes the database @nonterm{state-database}, which must have the suffix
1114       @filepath{.sqlite}, as the current state of @nonterm{dest-dir}.}
1115 @item{@DFlag{relative} --- Writes package sources to @nonterm{dest-catalog} in relative-path form.}
1116 @item{@DFlag{version} @nonterm{version} or @Flag{v} @nonterm{version} --- Copies catalog
1117       results specific to @nonterm{version}
1118       (for catalogs that make a distinction), instead of the installation's Racket version.}
1119  @item{@DFlag{pkg-fail} @nonterm{mode} --- Determines handling of failure for an individual
1120       package, such as when a @nonterm{src-catalog} contains a bad package source. The
1121       following @nonterm{mode}s are available:
1122       @itemlist[
1123         @item{@exec{fail} (the default) --- archiving stops and fails;}
1124         @item{@exec{skip} --- the package is skipped and omitted from the archive catalog; or}
1125         @item{@exec{continue} --- like @exec{skip}, but @exec{raco pkg catalog-archive}
1126               exits with a status code of @exec{5} if any package was skipped.}
1127       ]}
1128
1129 @item{@DFlag{include} @nonterm{pkg} --- Can be specified multiple times. If @DFlag{include} is
1130       specified at least once, then the archive and generated catalog includes only
1131       the @nonterm{pkg}s specified with @DFlag{include}, plus the dependencies
1132       of each @nonterm{pkg} if @DFlag{include-deps} is specified, modulo packages
1133       excluded via @DFlag{exclude}.}
1134 @item{@DFlag{include-deps} --- Modifies the @DFlag{includes} @nonterm{pkg} flag to imply all
1135       dependencies of @nonterm{pkg}.}
1136 @item{@DFlag{include-deps-platform} @nonterm{sys} @nonterm{subpath} --- Modifies @DFlag{include-deps}
1137       to imply only dependencies that match the platform @nonterm{sys}, which should be
1138       a possible result of @racket[(system-type)], and @nonterm{subpath}, which should be
1139       a possible result of @racket[(system-library-subpath #f)]}
1140 @item{@DFlag{exclude} @nonterm{pkg} --- Can be specified multiple times. Removes @nonterm{pkg}
1141       from the set of packages in the archive and generated catalog. If @DFlag{include} is
1142       used for the same @nonterm{pkg}, then @DFlag{exclude} takes
1143       precedence. If @DFlag{include} is used with
1144       @DFlag{include-deps} for @nonterm{pkg} or a package that depends on @nonterm{pkg},
1145       then @DFlag{exclude} stops the consideration of @nonterm{pkg}'s
1146       dependencies (but does not necessarily exclude the dependencies, because they
1147       may be dependencies of an included package).}
1148 @item{@DFlag{fast-file-copy} --- Directly copies package files from the @nonterm{src-catalog}s
1149       when available on the local filesystem, instead of extracting and repacking.}
1150 ]
1151
1152 @history[#:added "6.0.17"
1153          #:changed "7.7.0.1" @elem{Added @DFlag{include}, @DFlag{include-deps}, @DFlag{include-deps-platform},
1154                                    @DFlag{exclude}, and @DFlag{fast-file-copy}.}]
1155}
1156
1157@subcommand{@command/toc{archive} @nonterm{option} ... @nonterm{dest-dir} @nonterm{pkg} ...
1158--- Copies information from installed packages named by @nonterm{pkgs}s
1159    to a @filepath{catalog} directory catalog in @nonterm{dest-dir}, and also copies
1160    all package sources to a @filepath{pkgs} directory in @nonterm{dest-dir}.
1161
1162    Packages sources are copied and repacked as needed, so that
1163    all packages are written to the @filepath{pkgs} directory as
1164    @filepath{.zip} archives. This conversion may change the checksum
1165    on each archived package.
1166
1167    The @exec{archive} sub-command accepts
1168    the following @nonterm{option}s:
1169
1170 @itemlist[
1171 @item{@DFlag{include-deps} --- Includes the dependencies of the specified packages
1172        in the resulting catalog.}
1173 @item{@DFlag{exclude} @nonterm{pkg} --- Omits the specified @nonterm{pkg} from the
1174        resulting catalog. This also causes the dependencies of @nonterm{pkg} to be
1175        omitted if @DFlag{include-deps} is specified. This flag can be provided multiple times.}
1176 @item{@DFlag{relative} --- Writes package sources to @nonterm{dest-catalog} in relative-path form.}
1177 ]
1178
1179 @history[#:added "6.1.0.8"]
1180}
1181
1182@subcommand{@command/toc{empty-trash} @nonterm{option} ...
1183--- Removes or lists package implementations that were previously removed or updated and
1184    are currently in the trash directory
1185    for the specified @tech{package scope}. The @exec{trash-max-packages} and
1186    @exec{trash-max-seconds} configuration keys (see @command-ref{config}) control
1187    how many packages are kept in the trash directory and for how long.
1188
1189    The @exec{empty-trash} sub-command accepts
1190    the following @nonterm{option}s:
1191
1192 @itemlist[
1193 @item{@DFlag{scope} @nonterm{scope} --- Selects a @tech{package scope}, the same as for @command-ref{install}.}
1194 @item{@Flag{i} or @DFlag{installation} --- Shorthand for @exec{--scope installation}.}
1195 @item{@Flag{u} or @DFlag{user} --- Shorthand for @exec{--scope user}.}
1196 @item{@DFlag{scope-dir} @nonterm{dir} --- Same as for @command-ref{install}.}
1197
1198 @item{@DFlag{list} or @Flag{l} --- Shows the trash directory path and its content, instead of
1199                                    removing the current content.}
1200 ]
1201
1202 @history[#:added "6.1.1.6"]
1203}
1204
1205@; ----------------------------------------
1206
1207@section[#:tag "metadata"]{Package Metadata}
1208
1209Package metadata, including dependencies on other packages, is reported
1210by an @filepath{info.rkt} module within the package. This module must be
1211implemented in the @racketmodname[info] language.
1212
1213For example, a basic @filepath{info.rkt} file might be
1214
1215@codeblock{
1216#lang info
1217(define version "1.0")
1218(define deps (list _package-source-string ...))
1219}
1220
1221The following @filepath{info.rkt} fields are used by the package manager:
1222
1223@margin-note{
1224  When a package is a @tech{single collection package}, its @filepath{info.rkt}
1225  file may specify additional fields that are used for the Scribble documentation
1226  system or other tools. Many of these fields are described
1227  in @secref["setup-info" #:doc raco-doc].
1228}
1229
1230@(define (definfofield s) @as-index{@racketidfont{@s}})
1231
1232@itemlist[
1233
1234 @item{@definfofield{collection} --- either @racket['multi] to
1235       implement a @tech{multi-collection package} or a string or
1236       @racket['use-pkg-name] to implement a @tech{single-collection
1237       package}. If @racketidfont{collection} is defined as a string,
1238       then the string is used as the name of the collection
1239       implemented by the package. If @racketidfont{collection} is
1240       defined as @racket['use-pkg-name], then the package name is used
1241       as the package's collection name.
1242
1243       Beware that omitting @racketidfont{collection} or defining it
1244       as @racket['use-pkg-name] means that a package's content
1245       effectively changes with the package's name. A package's
1246       content should normally be independent of the package's name,
1247       and so defining @racketidfont{collection} to a string is
1248       preferable for a @tech{single-collection package}.}
1249
1250 @item{@definfofield{version} --- a @tech{version} string. The default
1251       @tech{version} of a package is @racket["0.0"].}
1252
1253 @item{@definfofield{deps} --- a list of dependencies, where each
1254       dependency has one of the following forms:
1255
1256       @itemlist[
1257
1258         @item{A string for a @tech{package source}.}
1259
1260         @item{A list of the form
1261               @racketblock[(list _package-source-string
1262                                  _keyword-and-spec ...)]
1263               where each @racket[_keyword-and-spec] has a
1264               distinct keyword in the form
1265               @racketgrammar*[#:literals (quote)
1266                               [keyword-and-spec
1267                                (code:line '#:version version-string)
1268                                (code:line '#:platform platform-spec)]
1269                               [platform-spec string symbol regexp]]
1270
1271               A @racket[_version-string] specifies a lower bound
1272               on an acceptable @tech{version} of the needed package.
1273
1274               A @racket[_platform-spec] indicates that the dependency
1275               applies only for platforms with a matching result from
1276               @racket[(system-type)] when @racket[_platforms-spec] is
1277               a symbol or @racket[(path->string
1278               (system-library-subpath #f))] when
1279               @racket[_platform-spec] is a string or regular expression.
1280               See also @racket[matching-platform?]. For
1281               example, platform-specific binaries can be placed into
1282               their own packages, with one separate package and one
1283               dependency for each supported platform.}
1284
1285         @item{A list of the form
1286               @racketblock[(list _package-source-string _version-string)]
1287               which is deprecated and equivalent to
1288               @racketblock[(list _package-source-string '#:version _version-string)]}
1289
1290        ]
1291
1292       Each element of the @racketidfont{deps} list determines a
1293       dependency on the @tech{package} whose name is inferred from
1294       the @tech{package source} (i.e., dependencies are on package
1295       names, not package sources), while the @tech{package source}
1296       indicates where to get the package if needed to satisfy the
1297       dependency.
1298
1299       Using the package name @racket["racket"] specifies a dependency
1300       on the Racket run-time system, which is potentially useful when
1301       a version is included in the dependency. For most purposes,
1302       it's better to specify a versioned dependency on
1303       @racket["base"], instead.
1304
1305       See also @secref["setup-check-deps" #:doc raco-doc].}
1306
1307 @item{@definfofield{build-deps} --- like @racketidfont{deps}, but for
1308       dependencies that can be omitted from a @tech{binary package},
1309       which does not include sources; see @secref["strip"] and
1310       @secref["setup-check-deps" #:doc raco-doc]. The
1311       @racketidfont{build-deps} and @racketidfont{deps} lists are
1312       appended, while @command-ref["create"] strips away
1313       @racketidfont{build-deps} when converting a package for
1314       @DFlag{binary} mode.}
1315
1316 @item{@definfofield{implies} --- a list of strings and
1317       @racket['core]. Each string refers to a package listed in
1318       @racketidfont{deps} and indicates that a dependency on the
1319       current package counts as a dependency on the named package;
1320       for example, the @pkgname{gui} package is defined to ensure
1321       access to all of the libraries provided by @pkgname{gui-lib},
1322       so the @filepath{info.rkt} file of @pkgname{gui} lists
1323       @racket["gui-lib"] in @racketidfont{implies}. Packages listed
1324       in @racketidfont{implies} list are treated specially by
1325       updating: implied packages are automatically updated whenever
1326       the implying package is updated. The special value
1327       @racket['core] is intended for use by an appropriate
1328       @pkgname{base} package to declare it as the representative of
1329       core Racket libraries.}
1330
1331 @item{@definfofield{update-implies} --- a list of strings. Each
1332       string refers to a package listed in @racketidfont{deps}
1333       or @racketidfont{build-deps}
1334       and indicates that the implied packages are automatically updated
1335       whenever the implying package is updated.}
1336
1337 @item{@definfofield{setup-collects} --- a list of path strings and/or
1338       lists of path strings, which are used as collection names to
1339       set up via @exec{raco setup} after the package is installed, or
1340       @racket['all] to indicate that all collections need to be
1341       setup. By default, only collections included in the package are
1342       set up (plus collections for global documentation indexes and
1343       links).}
1344
1345 @item{@definfofield{license} --- a @deftech{license S-expression}
1346  specifying the package's license. A license S-expression represents an @deftech{SPDX}
1347  @hyperlink["https://spdx.github.io/spdx-spec/appendix-IV-SPDX-license-expressions/"]{
1348   license expression} as a datum with the quoted form:
1349
1350  @racketgrammar[#:literals (AND OR WITH) license-sexp
1351                 license-id
1352                 (license-id WITH exception-id)
1353                 (license-sexp AND license-sexp)
1354                 (license-sexp OR license-sexp)]
1355
1356  @margin-note{See @elemref["spdx-plus-operator"]{further details below}
1357   about @racket[_license-id] and the @litchar{+} operator.}
1358
1359  where a:
1360
1361  @itemize[
1362 @item{@racket[_license-id] is a short-form identifier from the
1363    @hyperlink["https://spdx.org/licenses/index.html"]{SPDX License List},
1364    e.g@._ @racketvalfont{LGPL-3.0-or-later}, @racketvalfont{Apache-2.0},
1365    or @racket[BSD-3-Clause]; and an}
1366 @item{@racket[_exception-id] is an identifier from the
1367    @hyperlink["https://spdx.org/licenses/exceptions-index.html"]{
1368     SPDX License Exceptions} list, e.g@._ @racketvalfont{Classpath-exception-2.0}.}]
1369
1370  For example, packages in the main Racket distribution
1371  define @racketidfont{license} as:
1372  @racketblock[(define license
1373                 '(Apache-2.0 OR MIT))]
1374
1375  The grammar of @tech{license S-expressions} is designed so that
1376  @racket[(format "~s" license)] produces a string conforming to the grammar in
1377  @hyperlink["https://spdx.github.io/spdx-spec/appendix-IV-SPDX-license-expressions/"]{
1378  Appendix IV} and
1379  @hyperlink["https://spdx.github.io/spdx-spec/appendix-V-using-SPDX-short-identifiers-in-source-files/"]{
1380  Appendix V}
1381  of the SPDX Specification v2.2.0,
1382  which is specified in terms of character sequences.
1383
1384  @elemtag["spdx-plus-operator"]{If the @litchar{+} operator is used,}
1385  it must be written as part of the @racket[_license-id],
1386  e.g@._ @racketvalfont{AFL-2.0+}.
1387  Note that the @hyperlink["https://spdx.dev/ids/"]{SPDX Workgroup has deprecated}
1388  (under ``Allowing later versions of a license'') the use of the @litchar{+}
1389  operator with GNU licenses: thus, one writes
1390  @racketvalfont{AFL-2.0} or @racketvalfont{AFL-2.0+} but
1391  @racketvalfont{GPL-3.0-only} or @racketvalfont{GPL-3.0-or-later}
1392  (and neither @racket[GPL-3.0] nor @racket[GPL-3.0+] are correct).
1393 }
1394
1395 @item{@definfofield{distribution-preference} --- either
1396       @racket['source], @racket['built], or @racket['binary],
1397       indicating the most suitable distribution mode for the package
1398       (but not a guarantee that it will be distributed as
1399       such). Absence of this definition implies @racket['binary] if
1400       the package has no @filepath{.rkt} or @filepath{.scrbl} files
1401       other than @filepath{info.rkt} files, and if it has any
1402       @filepath{.so}, @filepath{.dll}, @filepath{.dylib}, or
1403       @filepath{.framework} files; otherwise, absence implies
1404       @racket['built].}
1405
1406 @item{@definfofield{package-content-state} --- a list of two items;
1407       the first item is @racket['binary], @racket['binary-lib], or
1408       @racket['built], and the second item is either @racket[#f] or a
1409       string to represent a Racket version for compiled content. This
1410       information is used by @exec{raco pkg install} or @exec{raco
1411       pkg update} with @DFlag{source}, @DFlag{binary}, or
1412       @DFlag{binary-lib} to ensure that the package content is
1413       consistent with the requested conversion; see also
1414       @secref["strip"]. Absence of this definition is treated the
1415       same as @racket[(list 'source #f)].}
1416
1417]
1418
1419@history[#:changed "6.1.0.5" @elem{Added @racketidfont{update-implies}.}
1420         #:changed "6.1.1.6" @elem{Added @racketidfont{distribution-preference}.}
1421         #:changed "8.2.0.7" @elem{Added @racketidfont{license}.}]
1422
1423@; ----------------------------------------
1424
1425@include-section["strip.scrbl"]
1426
1427@; ----------------------------------------
1428
1429@include-section["git-workflow.scrbl"]
1430
1431@; ----------------------------------------
1432
1433@include-section["apis.scrbl"]
1434
1435@include-section["catalog-protocol.scrbl"]
1436
1437@; ----------------------------------------
1438
1439@section{@|Planet1| Compatibility}
1440
1441PLT maintains a @tech{package catalog} to serve packages that
1442were developed using the original @seclink[#:doc '(lib
1443"planet/planet.scrbl") "top"]{@|Planet1|} package system.  This
1444compatibility catalog is at
1445@link["http://planet-compats.racket-lang.org/"]{http://planet-compats.racket-lang.org/},
1446which is included by default in the package-server search path.
1447
1448Copies of @|Planet1| packages are automatically created by the
1449server according to the following system: for all packages that are in
1450the @litchar{4.x} @|Planet1| repository, the latest minor version of
1451@tt{@nonterm{user}/@nonterm{package}.plt/@nonterm{major-version}} will be available as
1452@pkgname{planet-@nonterm{user}-@nonterm{package}@nonterm{major-version}}. For example,
1453@tt{jaymccarthy/opencl.plt/1} minor version @tt{2}, will be available as
1454@pkgname{planet-jaymccarthy-opencl1}.
1455
1456The contents of these copies is a single collection with the name
1457@filepath{@nonterm{user}/@nonterm{package}@nonterm{major-version}} with all the files from the
1458original @|Planet1| package in it.
1459
1460Each file has been transliterated to use direct Racket-style requires
1461rather than @|Planet1|-style requires. For example, if any file contains
1462@racket[(planet jaymccarthy/opencl/module)], then it is transliterated
1463to @racket[jaymccarthy/opencl1/module]. @emph{This transliteration is
1464purely syntactic and is trivial to confuse, but works for most
1465packages, in practice.} Any transliterations that occurred are automatically added as
1466dependencies for the compatibility package.
1467
1468We do not intend to improve this compatibility system much more over
1469time, because it is simply a stop-gap as developers port their @|Planet1|
1470packages to the new system. Additionally, the existence of the compatibility
1471server is not meant
1472to imply that we will be removing @|Planet1| from existence in the near
1473future.
1474
1475@; ----------------------------------------
1476
1477@section[#:style 'quiet]{FAQ}
1478
1479This section answers anticipated frequently asked questions about
1480the package manager.
1481
1482@subsection{Are package installations versioned with respect to the
1483Racket version?}
1484
1485Most Racket installations are configured to that installing a package
1486installs it for a specific user and a specific version of Racket. That
1487is, the @tech{package scope} is user- and version-specific. More
1488precisely, it is user-specific and installation-name-specific, where
1489an installation name is typically a Racket version.
1490
1491You can change the default @tech{package scope} (for a particular
1492Racket installation) with @command-ref{config}@exec{ -i --set
1493default-scope installation}, in which case package operations apply
1494for all users of a Racket installation.  You can also use the @Flag{i}
1495or @DFlag{installation} flag with a specific @exec{raco pkg} command,
1496instead of changing the default scope for all uses of @exec{raco
1497pkg}. Note that an installation-wide package is not exactly
1498version-specific, because the version of an installation can change if
1499it corresponds to a source-code checkout that is periodically updated
1500and rebuilt.
1501
1502If you change the default @tech{package scope}, you can use the
1503@Flag{u} or @DFlag{user} flag with a specific @exec{raco pkg} command
1504to perform the command with user-specific @tech{package scope}.
1505
1506@subsection{Where and how are packages installed?}
1507
1508User-specific and Racket-version-specific packages are in
1509@racket[(find-user-pkgs-dir)], and installation-wide packages
1510are in @racket[(find-pkgs-dir)]. They are linked as
1511collections (for single-collection packages) or collection roots (for
1512multi-collection packages) with @exec{raco link}.
1513
1514@subsection{How are user-specific and installation-wide @tech{package scopes}
1515related for conflict checking?}
1516
1517User-specific packages are checked against installation-wide packages
1518for package-name conflicts and provided-module
1519conflicts. Installation-wide packages are checked against
1520user-specific packages only for provided-module conflicts.
1521
1522Beware that a conflict-free, installation-wide change by one user can
1523create conflicts for a different user.
1524
1525@subsection{Do I need to change a package's version when I update a package with error fixes, @|etc|?}
1526
1527If you have new code for a package, then it should have a new
1528@tech{checksum}. When package updates are searched for, the checksum
1529of the installed package is compared with the checksum of the source,
1530if they are different, then the source is re-installed. This allows
1531code changes to be distributed. You do not need to declare an update a
1532version number, except to allow other package implementors to indicate
1533a dependency on particular features (where a bug fix might be
1534considered a feature, but it is not usually necessary to consider it
1535that way).
1536
1537@subsection{How can I specify which version of a package I depend on
1538if its interface has changed and I need an @emph{old} version?}
1539
1540In such a situation, the author of the package has released a
1541backwards incompatible edition of a package. The package manager provides
1542no help to deal with this situation (other than, of course, not
1543installing the ``update''). Therefore, package authors should not make
1544backwards incompatible changes to packages. Instead, they should
1545release a new package with a new name. For example, package
1546@pkgname{libgtk} might become @pkgname{libgtk2}. These packages
1547should be designed to not conflict with each other, as well.
1548
1549@subsection{How can I fix my installation to a specific set of package
1550implementations or @tech{checksums}?}
1551
1552Packages are updated only when you run a tool such as
1553@command-ref{update}, so packages are never updated
1554implicitly. Furthermore, you can snapshot a set of package archives
1555and install from those archives, instead of relying on package name
1556resolution through a @tech{package catalog}.
1557
1558If you want to control the resolution of package names (including
1559specific @tech{checksum}s) but not necessary keep a copy of all package
1560code (assuming that old @tech{checksum}s remain available, such as
1561through GitHub), you can create a snapshot of the @tech{package name}
1562to @tech{package source} mapping by using @command-ref{catalog-copy}.
1563For example,
1564
1565@commandline{raco pkg catalog-copy --from-config /home/joe/snapshot.sqlite}
1566
1567creates a snapshot @filepath{/home/joe/snapshot.sqlite} of the current
1568package name resolution, and then
1569
1570@commandline{raco pkg config --set catalogs file:///home/joe/snapshot.sqlite}
1571
1572directs all package-name resolution to the snapshot. You can configure
1573resolution for specific package names by editing the snapshot.
1574
1575You can go even further with
1576
1577@commandline{raco pkg catalog-archive --from-config /home/joe/snapshot/}
1578
1579which not only takes a snapshot of the catalog, but also takes a
1580snapshot of all package sources (so that you do not depend on the
1581original sources).
1582
1583
1584@subsection{How can I install a package without its documentation?}
1585
1586If package is available in the form of a @tech{built package}, then
1587you can use @exec{raco pkg install --binary-lib} to strip source,
1588tests, and documentation from a package before installing it.
1589
1590The main package catalog at @url{https://pkgs.racket-lang.org/} refers
1591to @tech{source packages}, not @tech{built packages}. Other catalogs
1592provide @tech{built packages}:
1593
1594@itemlist[
1595
1596 @item{For packages associated with a Racket distribution (such as the
1597       current release), the site that hosts the distribution will
1598       normally also host @tech{built packages}---but only for packages
1599       that are already included in the distribution.}
1600
1601 @item{Built variants of the @url{https://pkgs.racket-lang.org/}
1602       packages are currently provided by the catalog
1603       @url{https://pkg-build.racket-lang.org/server/built/catalog/}
1604       (for the current release only). See
1605       @hyperlink["https://pkg-build.racket-lang.org/about.html"]{the
1606       package-build service} for more information.}
1607
1608]
1609
1610Some packages have been split at the source level into separate
1611library, test, and documentation packages. For example,
1612@pkgname{net-lib} provides modules such as @racketmodname[net/cookie]
1613without documentation, while @pkgname{net-doc} provides documentation
1614and @pkgname{net-test} provides tests. The @pkgname{net} package
1615depends on @pkgname{net-lib} and @pkgname{net-doc}, and it implies
1616@pkgname{net-lib}, so you can install @pkgname{net} in a minimal
1617Racket distribution to get the libraries with documentation (and lots
1618of additional packages to support documentation), or install
1619@pkgname{net-lib} to get just the libraries.
1620
1621If you develop a package that is especially widely used or is
1622especially useful in a constrained installation environment, then
1623splitting your package into @pkgname{-lib}, @pkgname{-doc}, and
1624@pkgname{-test} components may be worthwhile. Most likely, you should
1625keep the packages together in a single source-code repository and use
1626metedata such as @racketidfont{implies} and
1627@racketidfont{update-implies} (see @secref["metadata"]) so that the
1628packages are updated in sync.
1629
1630
1631@subsection{Why is the package manager so different than @|Planet1|?}
1632
1633There are two fundamental differences between @|Planet1| and this package manager.
1634
1635The first is that @|Planet1| uses ``internal linking'' whereas the current package manager
1636uses ``external linking.'' For example, an individual module requires a
1637@|Planet1| package directly in a require statement:
1638
1639@racketblock[
1640 (require (planet game/tic-tac-toe/data/matrix))
1641]
1642
1643whereas using the package manager, the module would simply require the module of
1644interest:
1645
1646@racketblock[
1647 (require data/matrix)
1648]
1649
1650and would rely on the external system having the
1651@pkgname{tic-tac-toe} package installed.
1652
1653This change is good because it makes the origin of modules more
1654flexible---so that code can migrate in and out of the core, packages
1655can easily be split up, combined, or taken over by other authors, etc.
1656
1657This change is bad because it makes the meaning of your program
1658dependent on the state of the system.
1659
1660The second major difference is that @|Planet1| is committed to
1661guaranteeing that packages that never conflict with one another, so
1662that any number of major and minor versions of the same package can be
1663installed and used simultaneously. The package manager does not share this
1664commitment, so package authors and users must be mindful of potential
1665conflicts and plan around them.
1666
1667This change is good because it is simpler and lowers the burden of
1668maintenance (provided most packages don't conflict.)
1669
1670The change is bad because users must plan around potential conflicts.
1671
1672In general, the goal of the package manager is to be a lower-level
1673system, more like the package systems used by operating systems. The
1674goals of @|Planet1| are not bad, but we believe they are needed
1675infrequently and a system like @|Planet1| could be more easily built
1676atop the package manager than the reverse.
1677
1678In particular, our plans to mitigate the downsides of these changes
1679are documented in @secref["short-term"].
1680
1681@; ----------------------------------------
1682
1683@section{Future Plans}
1684
1685@subsection[#:tag "short-term"]{Short Term}
1686
1687This section lists some short term plans for the package manager. These are
1688important, but didn't block its release. The package manager will be considered
1689out of beta when these are completed.
1690
1691@itemlist[
1692
1693@item{The official catalog server will divide packages into three
1694categories: @reponame{ring-0}, @reponame{ring-1}, and @reponame{ring-2}. The definitions
1695for these categories are:
1696
1697 @itemlist[
1698
1699  @item{@reponame{ring-2} --- No restrictions.}
1700
1701  @item{@reponame{ring-1} --- Must not conflict any package
1702in @reponame{ring-1} or @reponame{ring-0}.}
1703
1704  @item{@reponame{ring-0} --- Must not conflict any package in @reponame{ring-1}
1705or @reponame{ring-0}. Must have documentation and tests. The author must be
1706responsive about fixing regressions against changes in Racket, etc.}
1707
1708 ]
1709
1710These categories will be curated by PLT.
1711
1712Our goal is for all packages to be in @reponame{ring-1}, with
1713@reponame{ring-2} as a temporary place while the curators work with the
1714authors of conflicting packages to determine how modules should be
1715renamed for unity.
1716
1717However, before curation is complete, each package will be
1718automatically placed in @reponame{ring-2} or @reponame{ring-1}
1719depending on its conflicts, with preference being given to older
1720packages. (For example, if a new package B conflicts with an old
1721package A, then A will be in @reponame{ring-1}, but B will be in
1722@reponame{ring-2}.) During curation, however, it is not necessarily
1723the case that older packages have preference. (For example,
1724@pkgname{tic-tac-toe} should probably not provide
1725@filepath{data/matrix.rkt}, but that could be spun off into another
1726package used by both @pkgname{tic-tac-toe} and
1727@pkgname{factory-optimize}.)
1728
1729In contrast, the @reponame{ring-0} category will be a special category that
1730authors may apply for. Admission requires a code audit and implies
1731a "stamp of approval" from PLT. In the future, packages in this
1732category will have more benefits, such as automatic regression testing
1733on DrDr, testing during releases, provided binaries, and advertisement
1734during installation.
1735
1736The @|Planet1| compatibility packages will also be included in
1737the @reponame{ring-1} category, automatically.
1738
1739}
1740
1741@item{In order to mitigate the costs of external linking vis a vis the
1742inability to understand code in isolation, we will create exception
1743printers that search for providers of modules on the configured
1744@tech{package catalogs}. For example, if a module requires
1745@filepath{data/matrix.rkt}, and it is not available, then the catalog will
1746be consulted to discover what packages provide it. @emph{Only packages
1747in @reponame{ring-1} or @reponame{ring-0} will be
1748returned.} (This category restriction ensures that the package to
1749install is unique.)
1750
1751Users can configure their systems to then automatically install the
1752package provided is has the appropriate category (i.e., some users may
1753wish to automatically install @reponame{ring-0} packages but not
1754@reponame{ring-1} packages, while others may not want to install
1755any.)
1756
1757This feature will be generalized across all @tech{package catalogs},
1758so users could maintain their own category definitions with
1759different policies.}
1760
1761]
1762
1763@subsection{Long Term}
1764
1765This section lists some long term plans for the package manager. Many of these
1766require a lot of cross-Racket integration.
1767
1768@itemlist[
1769
1770@item{The official catalog server is bare bones. It could conceivably do a lot
1771more: keep track of more statistics, enable "social" interactions
1772about packages, licenses, etc. Some of this is easy and obvious, but the
1773community's needs are unclear.}
1774
1775@item{It would be nice to encrypt information from the official
1776@tech{package catalog} with a public key shipped with Racket, and
1777allow other catalogs to implement a similar security scheme.}
1778
1779@item{Packages in the @reponame{ring-0} category should be tested on
1780DrDr. This would require a way to communicate information about how
1781they should be run to DrDr. This is currently done via the
1782@filepath{meta/props} script for things in the core. We should
1783generalize this script to a @filepath{meta/props.d} directory so that
1784packages can install DrDr metadata to it.}
1785
1786@item{We hope that this package system will encourage more incremental
1787improvements to pieces of Racket. In particular, it would be wonderful
1788to have a very thorough @filepath{data} collection of different
1789data-structures. However, our existing setup for Scribble would force
1790each new data structure to have a different top-level documentation
1791manual, rather than extending the documentation of the existing
1792@filepath{data} collection. Similar issues will exist for the
1793@filepath{net} and @filepath{file} collections. We should design a way
1794to have such "documentation plugins" in Scribble and support
1795similar "plugin" systems elsewhere in the code-base.}
1796
1797@item{The user interface could be improved. For example, it would be good if
1798DrRacket would poll for package updates periodically and if when it was first
1799started it would display available, popular packages.}
1800
1801]
1802
1803@; ----------------------------------------
1804
1805@include-section["implementation.scrbl"]
1806