Did you know ... Search Documentation:
prolog_pack.pl -- A package manager for Prolog
PublicShow source

The library(prolog_pack) provides the SWI-Prolog package manager. This library lets you inspect installed packages, install packages, remove packages, etc. This library complemented by the built-in predicates such as attach_packs/2 that makes installed packages available as libraries.

The important functionality of this library is encapsulated in the app pack. For help, run

swipl pack help
Source current_pack(?Pack) is nondet[private]
Source current_pack(?Pack, ?Dir) is nondet[private]
True if Pack is a currently installed pack.
Source pack_list_installed is det
List currently installed packages and report possible dependency issues.
Source pack_info(+Pack)
Print more detailed information about Pack.
Source pack_info_term(+PackDir, ?Info) is nondet[private]
True when Info is meta-data for the package PackName.
Source term_in_file(:Valid, +File, -Term) is nondet[private]
True when Term appears in file and call(Valid, Term) is true.
Source pack_info_term(?Term) is nondet[private]
True when Term describes name and arguments of a valid package info term.
Source pack_list(+Query) is det
Source pack_list(+Query, +Options) is det
Source pack_search(+Query) is det
Query package server and installed packages and display results. Query is matches case-insensitively against the name and title of known and installed packages. For each matching package, a single line is displayed that provides:
  • Installation status
    • p: package, not installed
    • i: installed package; up-to-date with public version
    • a: as i, but installed only as dependency
    • U: installed package; can be upgraded
    • A: installed package; newer than publically available
    • l: installed package; not on server
  • Name@Version
  • Name@Version(ServerVersion)
  • Title

Options processed:

installed(true)
Only list packages that are locally installed. Contacts the server to compare our local version to the latest available version.
outdated(true)
Only list packages that need to be updated. This option implies installed(true).
server((Server|false))
If false, do not contact the server. This implies installed(true). Otherwise, use the given pack server.

Hint: ?- pack_list(''). lists all known packages.

The predicates pack_list/1 and pack_search/1 are synonyms. Both contact the package server at https://www.swi-prolog.org to find available packages. Contacting the server can be avoided using the server(false) option.

Source join_status(+PacksIn, -PacksOut) is det[private]
Combine local and remote information to assess the status of each package. PacksOut is a list of pack(Name, Status, Version, URL). If the versions do not match, Version is VersionInstalled-VersionRemote and similar for thee URL.
Source local_search(+Query, -Packs:list(atom)) is det[private]
Search locally installed packs.
Source pack_install(+Spec:atom) is det
Source pack_install(+SpecOrList, +Options) is det
Install one or more packs from SpecOrList. SpecOrList is a single specification or a list of specifications. A specification is one of
  • A pack name. This queries the pack repository at https://www.swi-prolog.org
  • Archive file name
  • A http(s) URL of an archive file name. This URL may contain a star (*) for the version. In this case pack_install/1 asks for the directory content and selects the latest version.
  • An https GIT URL
  • A local directory name given as file:// URL
  • '.', in which case a relative symlink is created to the current directory (all other options for Spec make a copy of the files). Installation using a symlink is normally used during development of a pack.

Processes the options below. Default options as would be used by pack_install/1 are used to complete the provided Options. Note that pack_install/2 can be used through the SWI-Prolog command line app pack as below. Most of the options of this predicate are available as command line options.

swipl pack install <name>

Options:

url(+URL)
Source for downloading the package
pack_directory(+Dir)
Directory into which to install the package.
global(+Boolean)
If true, install in the XDG common application data path, making the pack accessible to everyone. If false, install in the XDG user application data path, making the pack accessible for the current user only. If the option is absent, use the first existing and writable directory. If that doesn't exist find locations where it can be created and prompt the user to do so.
insecure(+Boolean)
When true (default false), do not perform any checks on SSL certificates when downloading using https.
interactive(+Boolean)
Use default answer without asking the user if there is a default action.
silent(+Boolean)
If true (default false), suppress informational progress messages.
upgrade(+Boolean)
If true (default false), upgrade package if it is already installed.
rebuild(Condition)
Rebuild the foreign components. Condition is one of if_absent (default, do nothing if the directory with foreign resources exists), make (run make) or true (run `make distclean` followed by the default configure and build steps).
test(Boolean)
If true (default), run the pack tests.
git(+Boolean)
If true (default false unless URL ends with =.git=), assume the URL is a GIT repository.
link(+Boolean)
Can be used if the installation source is a local directory and the file system supports symbolic links. In this case the system adds the current directory to the pack registration using a symbolic link and performs the local installation steps.
version(+Version)
Demand the pack to satisfy some version requirement. Version is as defined by require_version/3. For example '1.5' is the same as >=('1.5').
branch(+Branch)
When installing from a git repository, clone this branch.
commit(+Commit)
When installing from a git repository, checkout this commit. Commit is either a hash, a tag, a branch or 'HEAD'.
build_type(+Type)
When building using CMake, use -DCMAKE_BUILD_TYPE=Type. Default is the build type of Prolog or Release.
register(+Boolean)
If true (default), register packages as downloaded after performing the download. This contacts the server with the meta-data of each pack that was downloaded. The server will either register the location as a new version or increment the download count. The server stores the IP address of the client. Subsequent downloads of the same version from the same IP address are ignored.
server(+URL)
Pack server to contact. Default is the setting prolog_pack:server, by default set to https://www.swi-prolog.org/pack/

Non-interactive installation can be established using the option interactive(false). It is adviced to install from a particular trusted URL instead of the plain pack name for unattented operation.

Source pack_default_options(+Spec, -Pack, +OptionsIn, -Options) is det[private]
Establish the pack name (Pack) and install options from a specification and options (OptionsIn) provided by the user. Cases:
  1. Already installed. We must pass that as pack_default_options/4 is called twice from pack_install/2.
  2. Install from a URL due to a url(URL) option. Determine whether the URL is a GIT repository, get the version and pack from the URL.
  3. Install a local archive file. Extract the pack and version from the archive name.
  4. Install from a git URL. Determines the pack, sets git(true) and adds the URL as option.
  5. Install from a directory. Get the info from the packs.pl file.
  6. Install from '.'. Create a symlink to make the current dir accessible as a pack.
  7. Install from a non-git URL Determine pack and version.
  8. Pack name. Query the server to find candidate packs and select an adequate pack.
Source pack_install_dir(-PackDir, +Options) is det[private]
Determine the directory below which to install new packs. This find or creates a writeable directory. Options:
  • pack_directory(+PackDir) Use PackDir. PackDir is created if it does not exist.
  • global(+Boolean) If true, find a writeable global directory based on the file search path common_app_data. If false, find a user-specific writeable directory based on user_app_data
  • If neither of the above is given, use the search path pack.

If no writeable directory is found, generate possible location where this directory can be created and ask the user to create one of them.

Source pack_unpack_from_local(+Source, +PackTopDir, +Name, -PackDir, +Options)[private]
Unpack a package from a local media. If Source is a directory, either copy or link the directory. Else, Source must be an archive file. Options:
link(+Boolean)
If the source is a directory, link or copy the directory?
upgrade(true)
If the target is already there, wipe it and make a clean install.
Source pack_unpack(+SourceFile, +PackDir, +Pack, +Options)[private]
Unpack an archive to the given package dir.
To be done
- If library(archive) is not provided we could check for a suitable external program such as tar or unzip.
Source pack_install_local(:Spec, +Dir, +Options) is det
Install a number of packages in a local directory. This predicate supports installing packages local to an application rather than globally.
Source known_media(+Pair) is semidet[private]
True when the options specify installation from a known media. If that applies to all packs, there is no need to query the server. We first download and unpack the known media, then examine the requirements and, if necessary, go to the server to resolve these.
Source pack_resolve(+Pairs, +Existing, +Versions, -Plan, +Options) is det[private]
Generate an installation plan. Pairs is a list of Pack-Options pairs that specifies the desired packages. Existing is a list of pack(Pack, i, Title, Version, URL) terms that represents the already installed packages. Versions is obtained from the server. See pack.pl from the web server for details. On success, this results in a Plan to satisfies the requirements. The plan is a list of packages to install with their location. The steps satisfy the partial ordering of dependencies, such that dependencies are installed before the dependents. Options:
upgrade(true)
When specified, we try to install the latest version of all the packages. Otherwise, we try to minimise the installation.
Source insert_existing(+Existing, +Available, -Candidates, +Options) is det[private]
Combine the already existing packages with the ones reported as available by the server to a list of Candidates, where the candidate of each package is ordered according by preference. When upgrade(true) is specified, the existing is merged into the set of Available versions. Otherwise Existing is prepended to Available, so it is selected as first.
Source can_upgrade(+Installed, +Versions, -Installed2) is det[private]
Add a latest_version key to Installed if its version is older than the latest available version.
Source mark_installed(+PlanA, +Existing, -Plan) is det[private]
Mark already up-to-date packs from the plan and add a key upgrade:true to elements of PlanA in Existing that are not the same.
Source select_version(+PackAndOptions, +Available, +Options)// is nondet[private]
True when the output is a list of pack info dicts that satisfy the installation requirements of PackAndOptions from the packs known to be Available.
 add_to_plan(+Info, +Versions, +Options) is semidet[private]
Add Info to the plan. If an Info about the same pack is already in the plan, but this is a different version of the pack, we must fail as we cannot install two different versions of a pack.
Source info_conflicts(+Info1, +Info2) is semidet[private]
True if Info2 is in conflict with Info2. The relation is symetric.
Source pack_satisfies(+Pack, +Version, +Info0, -Info, +Options) is semidet[private]
True if Pack@Version with Info satisfies the pack installation options provided by Options.
Source satisfies_version(+Pack, +PackVersion, +RequiredVersion) is semidet[private]
Source satisfies_req(+Provides, +Required) is semidet[private]
Check a token requirements.
Source pack_options_to_versions(+PackOptionsPair, -Versions) is det[private]
Create an available package term from Pack and Options if it contains a url(URL) option. This allows installing packages that are not known to the server. In most cases, the URL will be a git URL or the URL to download an archive. It can also be a file:// url to install from a local archive.

The first clause deals with a wildcard URL. See pack_default_options/4, case (7).

Source compatible_version(+Pack, +Version, +Options) is semidet[private]
Fails if Options demands a version and Version is not compatible with Version.
Source pack_options_compatible_with_info(+Info, +PackOptions) is semidet[private]
Ignore information from the server that is incompatible with the request.
 download_plan(+Targets, +Plan, +Options) is semidet[private]
Download or update all packages from Plan. We need to do this as a first step because we may not have (up-to-date) dependency information about all packs. For example, a pack may be installed at the git HEAD revision that is not yet know to the server or it may be installed from a url that is not known at all at the server.
Source plan_unsatisfied_dependencies(+Plan, -Deps) is det[private]
True when Deps is a list of dependency tokens in Plan that is not satisfied.
Source build_plan(+Plan, -Built, +Options) is det[private]
Run post installation steps. We build dependencies before their dependents, so we first do a topological sort on the packs based on the pack dependencies.
Source needs_rebuild(+PackDir, +Options) is semidet[private]
True when we need to rebuilt the pack in PackDir.
Source is_built(+PackDir, +Options) is semidet[private]
True if the pack in PackDir has been built.
To be done
- We now verify it was built by the exact same version. That is normally an overkill.
Source order_builds(+ToBuild, -Ordered) is det[private]
Order the build processes by building dependencies before the packages that rely on them as they may need them during the build.
Source exec_plan_rebuild_step(+Options, +Info) is det[private]
Execute the rebuild steps for the given Info.
Source attach_from_info(+Options, +Info) is det[private]
Make the package visible. Similar to pack_make_available/3.
Source download_from_info(+Options, +Info0, -Info) is det[private]
Download a package guided by Info. Note that this does not run any scripts. This implies that dependencies do not matter and we can proceed in any order. This is important because we may use packages at their git HEAD, which implies that requirements may be different from what is in the Info terms.
Source reload_info(+PackDir, +Info0, -Info) is det[private]
Update the requires and provides metadata. Info0 is what we got from the server, but the package may be different as we may have asked for the git HEAD or the package URL may not have been known by the server at all.
Source work_done(+Targets, +Plan, +PlanB, +Built, +Options) is det[private]
Targets has successfully been installed and the packs Built have successfully ran their build scripts.
Source local_packs(+Dir, -Packs) is det[private]
True when Packs is a list with information for all installed packages.
Source prolog_description(-Description) is det[private]
Provide a description of the running Prolog system. Version terms:
  • prolog(Dialect, Version)
To be done
- : establish a language for features. Sync with library(prolog_versions)
Source is_prolog_token(+Token) is semidet[private]
True when Token describes a property of the target Prolog system.
Source prolog_satisfies(+Token) is semidet[private]
True when the running Prolog system satisfies token. Processes requires(Token) terms for
  • prolog Cmp Version Demand a Prolog version (range).
  • prolog:Flag
  • prolog:Flag(Value)
  • prolog:library(Lib)
See also
- require_prolog_version/2.
Source pack_archive_info(+Archive, +Pack, -Info, -Strip)[private]
True when Archive archives Pack. Info is unified with the terms from pack.pl in the pack and Strip is the strip-option for archive_extract/3.

Requires library(archive), which is lazily loaded when needed.

Errors
- existence_error(pack_file, 'pack.pl') if the archive doesn't contain pack.pl
- Syntax errors if pack.pl cannot be parsed.
Source pack_git_info(+GitDir, -Hash, -Info) is det[private]
Retrieve info from a cloned git repository that is compatible with pack_archive_info/4.
Source download_file_sanity_check(+Archive, +Pack, +Info) is semidet[private]
Perform basic sanity checks on DownloadFile
Source prepare_pack_dir(+Dir, +Options)[private]
Prepare for installing the package into Dir. This
  • If the directory exist and is empty, done.
  • Else if the directory exists, remove the directory and recreate it. Note that if the directory is a symlink this just deletes the link.
  • Else if some entry (file, link, ...) exists, delete it and create a new directory.
  • Else create the directory.
Source empty_directory(+Directory) is semidet[private]
True if Directory is empty (holds no files or sub-directories).
Source remove_existing_pack(+PackDir, +Options) is semidet[private]
Remove a possible existing pack directory if the option upgrade(true) is present. This is used to remove an old installation before unpacking a new archive, copy or link a directory with the new contents.
Source pack_download_from_url(+URL, +PackDir, +Pack, +Options)[private]
Download a package from a remote source. For git repositories, we simply clone. Archives are downloaded. Options:
git(true)
Assume URL refers to a git repository.
pack_dir(-Dir)
Dir is unified with the location where the pack is installed.
To be done
- We currently use the built-in HTTP client. For complete coverage, we should consider using an external (e.g., curl) if available.
Source git_checkout_version(+PackDir, +Options) is det[private]
Given a checked out version of a repository, put the repo at the desired version. Options:
commit(+Commit)
Target commit or 'HEAD'. If 'HEAD', get the HEAD of the explicit (option branch(Branch)), current or default branch. If the commit is a hash and it is the tip of a branch, checkout this branch. Else simply checkout the hash.
branch(+Branch)
Used with commit('HEAD').
version(+Version)
Checkout a tag. If there is a tag matching Version use that, otherwise try to find a tag that ends with Version and demand the prefix to be letters, optionally followed by a dash or underscore. Examples: 2.1, V2.1, v_2.1.
update(true)
If none of the above is given update the repo. If it is on a branch, pull. Else, put it on the default branch and pull.
Source git_ensure_on_branch(+PackDir, +Branch) is det[private]
Ensure PackDir is on Branch.
Source download_file(+URL, +Pack, -File, +Options) is det[private]
Determine the file into which to download URL. The second clause deals with GitHub downloads from a release tag.
Source pack_url_file(+URL, -File) is det
True if File is a unique id for the referenced pack and version. Normally, that is simply the base name, but GitHub archives destroy this picture. Needed by the pack manager in the web server.
Source download_url(@URL) is semidet[private]
True if URL looks like a URL we can download from. Noet that urls like ftp:// are also download URLs, but we cannot download from them.
Source pack_post_install(+Pack, +PackDir, +Options) is det[private]
Process post installation work. Steps:
  • Create foreign resources
  • Register directory as autoload library
  • Attach the package
Source pack_rebuild is det
Source pack_rebuild(+Pack) is det
Rebuild possible foreign components of Pack. The predicate pack_rebuild/0 rebuilds all registered packs.
Source post_install_foreign(+Pack, +PackDir, +Options) is det[private]
Install foreign parts of the package. Options:
rebuild(When)
Determine when to rebuild. Possible values:
if_absent
Only rebuild if we have no existing foreign library. This is the default.
true
Always rebuild.
Source foreign_present(+PackDir, +Arch) is semidet[private]
True if we find one or more modules in the pack lib directory for the current architecture.
To be done
- Does not check that these can be loaded, nor whether all required modules are present.
Source is_foreign_pack(+PackDir, -Type) is nondet[private]
True when PackDir contains files that indicate the need for a specific class of build tools indicated by Type.
Source post_install_autoload(+PackDir, +Options)[private]
Create an autoload index if the package demands such.
Source pack_upgrade(+Pack) is semidet
Upgrade Pack. Shorthand for pack_install(Pack, [upgrade(true)]).
Source pack_remove(+Name) is det
Source pack_remove(+Name, +Options) is det
Remove the indicated package. If packages depend (indirectly) on this pack, ask to remove these as well. Options:
interactive(false)
Do not prompt the user.
dependencies(Boolean)
If true delete dependencies without asking.
Source pack_publish(+Spec, +Options) is det
Publish a package. There are two ways typical ways to call this. We recommend developing a pack in a GIT repository. In this scenario the pack can be published using
?- pack_publish('.', []).

Alternatively, an archive file has been uploaded to a public location. In this scenario we can publish the pack using

?- pack_publish(URL, [])

In both scenarios, pack_publish/2 by default creates an isolated environment and installs the package in this directory from the public URL. On success it triggers the pack server to register the URL as a new pack or a new release of a pack.

Packs may also be published using the app pack, e.g.

swipl pack publish .

Options:

git(Boolean)
If true, and Spec is a git managed directory, install using the remote repo.
sign(Boolean)
Sign the repository with the current version. This runs git tag -s <tag>.
force(Boolean)
Force the git tag. This runs git tag -f <tag>.
branch(+Branch)
Branch used for releases. Defined by git_default_branch/2 if not specified.
register(+Boolean)
If false (default true), perform the installation, but do not upload to the server. This can be used for testing.
isolated(+Boolean)
If true (default), install and build all packages in an isolated package directory. If false, use other packages installed for the environment. The latter may be used to speedup debugging.
pack_directory(+Dir)
Install the temporary packages in Dir. If omitted pack_publish/2 creates a temporary directory and deletes this directory after completion. An explict target Dir is created if it does not exist and is not deleted on completion.
clean(+Boolean)
If true (default), clean the destination directory first
Source prepare_repository(+Dir, +Metadata, +Options) is semidet[private]
Prepare the git repository. If register(false) is provided, this is a test run and therefore we do not need this. Otherwise we demand the working directory to be clean, we tag the current commit and push the current branch.
Source tag_git_dir(+Dir, +Metadata, -Action, +Options) is semidet[private]
Add a version tag to the git repository.
Arguments:
Action- is one of push_tag(Tag) or none
Source git_to_https_url(+GitURL, -HTTP_URL) is semidet[private]
Get the HTTP(s) URL for a git repository, given a git url. Whether or not this is available and how to translate the one into the other depends in the server software.
Source pack_property(?Pack, ?Property) is nondet
True when Property is a property of an installed Pack. This interface is intended for programs that wish to interact with the package manager. Defined properties are:
directory(Directory)
Directory into which the package is installed
version(Version)
Installed version
title(Title)
Full title of the package
author(Author)
Registered author
download(URL)
Official download URL
readme(File)
Package README file (if present)
todo(File)
Package TODO file (if present)
Source pack_version_file(-Pack, -Version:atom, +File) is semidet[private]
True if File is the name of a file or URL of a file that contains Pack at Version. File must have an extension and the basename must be of the form <pack>-<n>{.<m>}*. E.g., mypack-1.5.
Source safe_pack_name(+Name:atom) is semidet[private]
Verifies that Name is a valid pack name. This avoids trickery with pack file names to make shell commands behave unexpectly.
Source pack_version(-Pack:atom, -Version:atom)// is semidet[private]
True when the input statifies <pack>-<version>
Source git_url(+URL, -Pack) is semidet[private]
True if URL describes a git url for Pack
Source github_release_url(+URL, -Pack, -Version:atom) is semidet[private]
True when URL is the URL of a GitHub release. Such releases are accessible as
https:/github.com/<owner>/<pack>/archive/[vV]?<version>.zip'
Source tag_version(+GitTag, -Version) is semidet[private]
True when a GIT tag describes version Version. GitTag must satisfy [vV]?int(\.int)*.
Source git_archive_url(+URL, -Archive, +Options) is semidet[private]
If we do not have git installed, some git services offer downloading the code as an archive using HTTP. This predicate makes this translation.
Source publish_download(+Infos, +Options) is semidet[private]
Source register_downloads(+Infos, +Options) is det[private]
Register our downloads with the pack server.
Source query_pack_server(+Query, -Result, +Options)[private]
Send a Prolog query to the package server and process its results.
Source available_download_versions(+URL, -Versions:list(atom)) is det[private]
Deal with wildcard URLs, returning a list of Version-URL pairs, sorted by version.
To be done
- Deal with protocols other than HTTP
Source sort_version_pairs(+Pairs, -Sorted) is det[private]
Sort a list of Version-Data by decreasing version.
Source github_url(+URL, -User, -Repo) is semidet[private]
True when URL refers to a github repository.
Source github_version(+User, +Repo, -Version, -VersionURI) is nondet[private]
True when Version is a release version and VersionURI is the download location for the zip file.
Source pack_provides(?Pack, -Provides) is multi[private]
Source pack_requires(?Pack, -Requires) is nondet[private]
Source pack_conflicts(?Pack, -Conflicts) is nondet[private]
Provide logical access to pack dependency relations.
Source pack_depends_on(?Pack, ?Dependency) is nondet[private]
True when Pack depends on pack Dependency. This predicate does not deal with transitive dependency.
Source dependents(+Pack, -Dependents) is semidet[private]
True when Dependents is a list of packs that (indirectly) depend on Pack.
Source validate_dependencies is det[private]
Validate all dependencies, reporting on failures
Source pack_dependency_issue(?Pack, -Issue) is nondet[private]
True when Issue is a dependency issue regarding Pack. Issue is one of
unsatisfied(Pack, Requires)
The requirement Requires of Pack is not fulfilled.
conflicts(Pack, Conflict)
Pack conflicts with Conflict.
Source pack_assert(+PackDir, ++Fact) is det[private]
Add/update a fact about packs. These facts are stored in PackDir/status.db. Known facts are:
built(Arch, Version, How)
Pack has been built by SWI-Prolog Version for Arch. How is one of built if we built it or downloaded if it was downloaded.
automatic(Boolean)
If true, pack was installed as dependency.
archive(Archive, URL)
Available when the pack was installed by unpacking Archive that was retrieved from URL.
Source pack_status(?Pack, ?Fact)[private]
Source pack_status_dir(+PackDir, ?Fact)[private]
True when Fact is true about the package in PackDir. Facts are asserted a file status.db.
Source update_automatic(+Info) is det[private]
Update the automatic status of a package. If we install it has no automatic status and we install it as a dependency we mark it as automatic. Else, we mark it as non-automatic as it has been installed explicitly.
Source menu(Question, +Alternatives, +Default, -Selection, +Options)[private]
Source confirm(+Question, +Default, +Options) is semidet[private]
Ask for confirmation.
Arguments:
Default- is one of yes, no or none.
Source install_plan(+Plan, -Actions)// is det[private]
Source install_label(+Actions)// is det[private]
Describe the overall installation plan before downloading.
Source msg_build_plan(+Plan)//[private]
Describe the build plan before running the build steps.

Re-exported predicates

The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.

Source pack_list(+Query) is det
Source pack_list(+Query, +Options) is det
Source pack_search(+Query) is det
Query package server and installed packages and display results. Query is matches case-insensitively against the name and title of known and installed packages. For each matching package, a single line is displayed that provides:
  • Installation status
    • p: package, not installed
    • i: installed package; up-to-date with public version
    • a: as i, but installed only as dependency
    • U: installed package; can be upgraded
    • A: installed package; newer than publically available
    • l: installed package; not on server
  • Name@Version
  • Name@Version(ServerVersion)
  • Title

Options processed:

installed(true)
Only list packages that are locally installed. Contacts the server to compare our local version to the latest available version.
outdated(true)
Only list packages that need to be updated. This option implies installed(true).
server((Server|false))
If false, do not contact the server. This implies installed(true). Otherwise, use the given pack server.

Hint: ?- pack_list(''). lists all known packages.

The predicates pack_list/1 and pack_search/1 are synonyms. Both contact the package server at https://www.swi-prolog.org to find available packages. Contacting the server can be avoided using the server(false) option.

Source pack_list(+Query) is det
Source pack_list(+Query, +Options) is det
Source pack_search(+Query) is det
Query package server and installed packages and display results. Query is matches case-insensitively against the name and title of known and installed packages. For each matching package, a single line is displayed that provides:
  • Installation status
    • p: package, not installed
    • i: installed package; up-to-date with public version
    • a: as i, but installed only as dependency
    • U: installed package; can be upgraded
    • A: installed package; newer than publically available
    • l: installed package; not on server
  • Name@Version
  • Name@Version(ServerVersion)
  • Title

Options processed:

installed(true)
Only list packages that are locally installed. Contacts the server to compare our local version to the latest available version.
outdated(true)
Only list packages that need to be updated. This option implies installed(true).
server((Server|false))
If false, do not contact the server. This implies installed(true). Otherwise, use the given pack server.

Hint: ?- pack_list(''). lists all known packages.

The predicates pack_list/1 and pack_search/1 are synonyms. Both contact the package server at https://www.swi-prolog.org to find available packages. Contacting the server can be avoided using the server(false) option.

Source pack_install(+Spec:atom) is det
Source pack_install(+SpecOrList, +Options) is det
Install one or more packs from SpecOrList. SpecOrList is a single specification or a list of specifications. A specification is one of
  • A pack name. This queries the pack repository at https://www.swi-prolog.org
  • Archive file name
  • A http(s) URL of an archive file name. This URL may contain a star (*) for the version. In this case pack_install/1 asks for the directory content and selects the latest version.
  • An https GIT URL
  • A local directory name given as file:// URL
  • '.', in which case a relative symlink is created to the current directory (all other options for Spec make a copy of the files). Installation using a symlink is normally used during development of a pack.

Processes the options below. Default options as would be used by pack_install/1 are used to complete the provided Options. Note that pack_install/2 can be used through the SWI-Prolog command line app pack as below. Most of the options of this predicate are available as command line options.

swipl pack install <name>

Options:

url(+URL)
Source for downloading the package
pack_directory(+Dir)
Directory into which to install the package.
global(+Boolean)
If true, install in the XDG common application data path, making the pack accessible to everyone. If false, install in the XDG user application data path, making the pack accessible for the current user only. If the option is absent, use the first existing and writable directory. If that doesn't exist find locations where it can be created and prompt the user to do so.
insecure(+Boolean)
When true (default false), do not perform any checks on SSL certificates when downloading using https.
interactive(+Boolean)
Use default answer without asking the user if there is a default action.
silent(+Boolean)
If true (default false), suppress informational progress messages.
upgrade(+Boolean)
If true (default false), upgrade package if it is already installed.
rebuild(Condition)
Rebuild the foreign components. Condition is one of if_absent (default, do nothing if the directory with foreign resources exists), make (run make) or true (run `make distclean` followed by the default configure and build steps).
test(Boolean)
If true (default), run the pack tests.
git(+Boolean)
If true (default false unless URL ends with =.git=), assume the URL is a GIT repository.
link(+Boolean)
Can be used if the installation source is a local directory and the file system supports symbolic links. In this case the system adds the current directory to the pack registration using a symbolic link and performs the local installation steps.
version(+Version)
Demand the pack to satisfy some version requirement. Version is as defined by require_version/3. For example '1.5' is the same as >=('1.5').
branch(+Branch)
When installing from a git repository, clone this branch.
commit(+Commit)
When installing from a git repository, checkout this commit. Commit is either a hash, a tag, a branch or 'HEAD'.
build_type(+Type)
When building using CMake, use -DCMAKE_BUILD_TYPE=Type. Default is the build type of Prolog or Release.
register(+Boolean)
If true (default), register packages as downloaded after performing the download. This contacts the server with the meta-data of each pack that was downloaded. The server will either register the location as a new version or increment the download count. The server stores the IP address of the client. Subsequent downloads of the same version from the same IP address are ignored.
server(+URL)
Pack server to contact. Default is the setting prolog_pack:server, by default set to https://www.swi-prolog.org/pack/

Non-interactive installation can be established using the option interactive(false). It is adviced to install from a particular trusted URL instead of the plain pack name for unattented operation.

Source pack_rebuild is det
Source pack_rebuild(+Pack) is det
Rebuild possible foreign components of Pack. The predicate pack_rebuild/0 rebuilds all registered packs.
Source pack_remove(+Name) is det
Source pack_remove(+Name, +Options) is det
Remove the indicated package. If packages depend (indirectly) on this pack, ask to remove these as well. Options:
interactive(false)
Do not prompt the user.
dependencies(Boolean)
If true delete dependencies without asking.