This section describes the functional API for interacting with Pkg.jl. It is recommended to use the functional API, rather than the Pkg REPL mode, for non-interactive usage, for example in scripts.
Certain options are generally useful and can be specified in any API call. You can specify these options by setting keyword arguments.
Use theio::IOBuffer
keyword argument to redirect Pkg output. For example,Pkg.add("Example"; io=devnull)
will discard any output produced by theadd
call.
In the Pkg REPL mode, packages (with associated version, UUID, URL etc) are parsed from strings, for example"Package#master"
,"Package@v0.1"
,"www.mypkg.com/MyPkg#my/feature"
.
In the functional API, it is possible to use strings as arguments for simple commands (likePkg.add(["PackageA", "PackageB"])
, but more complicated commands, which e.g. specify URLs or version range, require the use of a more structured format over strings. This is done by creating an instance ofPackageSpec
which is passed in to functions.
Pkg.add
—FunctionPkg.add(pkg::Union{String, Vector{String}}; preserve=PRESERVE_TIERED, target::Symbol=:deps)Pkg.add(pkg::Union{PackageSpec, Vector{PackageSpec}}; preserve=PRESERVE_TIERED, target::Symbol=:deps)
Add a package to the current project. This package will be available by using theimport
andusing
keywords in the Julia REPL, and if the current project is a package, also inside that package.
If the active environment is a package (the Project has bothname
anduuid
fields) compat entries will be added automatically with a lower bound of the added version.
To add as a weak dependency (in the[weakdeps]
field) set the kwargtarget=:weakdeps
. To add as an extra dep (in the[extras]
field) settarget=:extras
.
Resolution Tiers
Pkg
resolves the set of packages in your environment using a tiered algorithm. Thepreserve
keyword argument allows you to key into a specific tier in the resolve algorithm. The following table describes the argument values forpreserve
(in order of strictness):
Value | Description |
---|---|
PRESERVE_ALL_INSTALLED | LikePRESERVE_ALL and only add those already installed |
PRESERVE_ALL | Preserve the state of all existing dependencies (including recursive dependencies) |
PRESERVE_DIRECT | Preserve the state of all existing direct dependencies |
PRESERVE_SEMVER | Preserve semver-compatible versions of direct dependencies |
PRESERVE_NONE | Do not attempt to preserve any version information |
PRESERVE_TIERED_INSTALLED | LikePRESERVE_TIERED exceptPRESERVE_ALL_INSTALLED is tried first |
PRESERVE_TIERED | Use the tier that will preserve the most version information while |
allowing version resolution to succeed (this is the default) |
To change the default strategy toPRESERVE_TIERED_INSTALLED
set the env varJULIA_PKG_PRESERVE_TIERED_INSTALLED
to true.
After the installation of new packages the project will be precompiled. For more information seepkg> ?precompile
.
With thePRESERVE_ALL_INSTALLED
strategy the newly added packages will likely already be precompiled, but if not this may be because either the combination of package versions resolved in this environment has not been resolved and precompiled before, or the precompile cache has been deleted by the LRU cache storage (seeJULIA_MAX_NUM_PRECOMPILE_FILES
).
ThePRESERVE_TIERED_INSTALLED
andPRESERVE_ALL_INSTALLED
strategies requires at least Julia 1.9.
Examples
Pkg.add("Example") # Add a package from registryPkg.add("Example", target=:weakdeps) # Add a package as a weak dependencyPkg.add("Example", target=:extras) # Add a package to the `[extras]` listPkg.add("Example"; preserve=Pkg.PRESERVE_ALL) # Add the `Example` package and strictly preserve existing dependenciesPkg.add(name="Example", version="0.3") # Specify version; latest release in the 0.3 seriesPkg.add(name="Example", version="0.3.1") # Specify version; exact releasePkg.add(url="https://github.com/JuliaLang/Example.jl", rev="master") # From url to remote gitrepoPkg.add(url="/remote/mycompany/juliapackages/OurPackage") # From path to local gitrepoPkg.add(url="https://github.com/Company/MonoRepo", subdir="juliapkgs/Package.jl)") # With subdir
After the installation of new packages the project will be precompiled. See more atEnvironment Precompilation.
See alsoPackageSpec
,Pkg.develop
.
Pkg.develop
—FunctionPkg.develop(pkg::Union{String, Vector{String}}; io::IO=stderr, preserve=PRESERVE_TIERED, installed=false)Pkg.develop(pkgs::Union{PackageSpec, Vector{PackageSpec}}; io::IO=stderr, preserve=PRESERVE_TIERED, installed=false)
Make a package available for development by tracking it by path. Ifpkg
is given with only a name or by a URL, the package will be downloaded to the location specified by the environment variableJULIA_PKG_DEVDIR
, withjoinpath(DEPOT_PATH[1],"dev")
being the default.
Ifpkg
is given as a local path, the package at that path will be tracked.
The preserve strategies offered byPkg.add
are also available via thepreserve
kwarg. SeePkg.add
for more information.
Examples
# By namePkg.develop("Example")# By urlPkg.develop(url="https://github.com/JuliaLang/Compat.jl")# By pathPkg.develop(path="MyJuliaPackages/Package.jl")
See alsoPackageSpec
,Pkg.add
.
Pkg.activate
—FunctionPkg.activate([s::String]; shared::Bool=false, io::IO=stderr)Pkg.activate(; temp::Bool=false, shared::Bool=false, io::IO=stderr)
Activate the environment ats
. The active environment is the environment that is modified by executing package commands. The logic for what path is activated is as follows:
shared
istrue
, the first existing environment nameds
from the depots in the depot stack will be activated. If no such environment exists, create and activate that environment in the first depot.temp
istrue
this will create and activate a temporary environment which will be deleted when the julia process is exited.s
is an existing path, then activate the environment at that path.s
is a package in the current project ands
is tracking a path, then activate the environment at the tracked path.s
is interpreted as a non-existing path, which is then activated.If no argument is given toactivate
, then use the first project found inLOAD_PATH
(ignoring"@"
). For the default value ofLOAD_PATH
, the result is to activate the@v#.#
environment.
Examples
Pkg.activate()Pkg.activate("local/path")Pkg.activate("MyDependency")Pkg.activate(; temp=true)
See alsoLOAD_PATH
.
Pkg.rm
—FunctionPkg.rm(pkg::Union{String, Vector{String}}; mode::PackageMode = PKGMODE_PROJECT)Pkg.rm(pkg::Union{PackageSpec, Vector{PackageSpec}}; mode::PackageMode = PKGMODE_PROJECT)
Remove a package from the current project. Ifmode
is equal toPKGMODE_MANIFEST
also remove it from the manifest including all recursive dependencies ofpkg
.
See alsoPackageSpec
,PackageMode
.
Pkg.update
—FunctionPkg.update(; level::UpgradeLevel=UPLEVEL_MAJOR, mode::PackageMode = PKGMODE_PROJECT, preserve::PreserveLevel)Pkg.update(pkg::Union{String, Vector{String}})Pkg.update(pkg::Union{PackageSpec, Vector{PackageSpec}})
If no positional argument is given, update all packages in the manifest ifmode
isPKGMODE_MANIFEST
and packages in both manifest and project ifmode
isPKGMODE_PROJECT
. If no positional argument is given,level
can be used to control by how much packages are allowed to be upgraded (major, minor, patch, fixed).
If packages are given as positional arguments, thepreserve
argument can be used to control what other packages are allowed to update:
PRESERVE_ALL
(default): Only allowpkg
to update.PRESERVE_DIRECT
: Only allowpkg
and indirect dependencies that are not a direct dependency in the project to update.PRESERVE_NONE
: Allowpkg
and all its indirect dependencies to update.After any package updates the project will be precompiled. See more atEnvironment Precompilation.
See alsoPackageSpec
,PackageMode
,UpgradeLevel
.
Pkg.test
—FunctionPkg.test(; kwargs...)Pkg.test(pkg::Union{String, Vector{String}; kwargs...)Pkg.test(pkgs::Union{PackageSpec, Vector{PackageSpec}}; kwargs...)
Keyword arguments:
coverage::Union{Bool,String}=false
: enable or disable generation of coverage statistics for the tested package. If a string is passed it is passed directly to--code-coverage
in the test process so e.g. "user" will test all user code.allow_reresolve::Bool=true
: allow Pkg to reresolve the package versions in the test environmentjulia_args::Union{Cmd, Vector{String}}
: options to be passed the test process.test_args::Union{Cmd, Vector{String}}
: test arguments (ARGS
) available in the test process.Run the tests for packagepkg
, or for the current project (which thus needs to be a package) if no positional argument is given toPkg.test
. A package is tested by running itstest/runtests.jl
file.
The tests are run by generating a temporary environment with only thepkg
package and its (recursive) dependencies in it. If a manifest file exists and theallow_reresolve
keyword argument is set tofalse
, the versions in the manifest file are used. Otherwise a feasible set of packages is resolved and installed.
During the tests, test-specific dependencies are active, which are given in the project file as e.g.
[extras]Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"[targets]test = ["Test"]
The tests are executed in a new process withcheck-bounds=yes
and by defaultstartup-file=no
. If using the startup file (~/.julia/config/startup.jl
) is desired, start julia with--startup-file=yes
. Inlining of functions during testing can be disabled (for better coverage accuracy) by starting julia with--inline=no
. The tests can be run as if different command line arguments were passed to julia by passing the arguments instead to thejulia_args
keyword argument, e.g.
Pkg.test("foo"; julia_args=["--inline"])
To pass some command line arguments to be used in the tests themselves, pass the arguments to thetest_args
keyword argument. These could be used to control the code being tested, or to control the tests in some way. For example, the tests could have optional additional tests:
if "--extended" in ARGS @test some_function()end
which could be enabled by testing with
Pkg.test("foo"; test_args=["--extended"])
Pkg.build
—FunctionPkg.build(; verbose = false, io::IO=stderr)Pkg.build(pkg::Union{String, Vector{String}}; verbose = false, io::IO=stderr)Pkg.build(pkgs::Union{PackageSpec, Vector{PackageSpec}}; verbose = false, io::IO=stderr)
Run the build script indeps/build.jl
forpkg
and all of its dependencies in depth-first recursive order. If no argument is given tobuild
, the current project is built, which thus needs to be a package. This function is called automatically on any package that gets installed for the first time.verbose = true
prints the build output tostdout
/stderr
instead of redirecting to thebuild.log
file.
Pkg.pin
—FunctionPkg.pin(pkg::Union{String, Vector{String}}; io::IO=stderr, all_pkgs::Bool=false)Pkg.pin(pkgs::Union{PackageSpec, Vector{PackageSpec}}; io::IO=stderr, all_pkgs::Bool=false)
Pin a package to the current version (or the one given in thePackageSpec
) or to a certain git revision. A pinned package is never automatically updated: ifpkg
is tracking a path, or a repository, those remain tracked but will not update. To get updates from the origin path or remote repository the package must first be freed.
Examples
Pkg.pin("Example")Pkg.pin(name="Example", version="0.3.1")Pkg.pin(all_pkgs = true)
Pkg.free
—FunctionPkg.free(pkg::Union{String, Vector{String}}; io::IO=stderr, all_pkgs::Bool=false)Pkg.free(pkgs::Union{PackageSpec, Vector{PackageSpec}}; io::IO=stderr, all_pkgs::Bool=false)
Ifpkg
is pinned, remove the pin. Ifpkg
is tracking a path, e.g. afterPkg.develop
, go back to tracking registered versions. To free all dependencies setall_pkgs=true
.
Examples
Pkg.free("Package")Pkg.free(all_pkgs = true)
Pkg.instantiate
—FunctionPkg.instantiate(; verbose = false, io::IO=stderr)
If aManifest.toml
file exists in the active project, download all the packages declared in that manifest. Otherwise, resolve a set of feasible packages from theProject.toml
files and install them.verbose = true
prints the build output tostdout
/stderr
instead of redirecting to thebuild.log
file. If noProject.toml
exist in the current active project, create one with all the dependencies in the manifest and instantiate the resulting project.
After packages have been installed the project will be precompiled. See more atEnvironment Precompilation.
Pkg.resolve
—FunctionPkg.resolve(; io::IO=stderr)
Update the current manifest with potential changes to the dependency graph from packages that are tracking a path.
Pkg.gc
—FunctionPkg.gc(; collect_delay::Period=Day(7), io::IO=stderr)
Garbage-collect package and artifact installations by sweeping over all knownManifest.toml
andArtifacts.toml
files, noting those that have been deleted, and then finding artifacts and packages that are thereafter not used by any other projects, marking them as "orphaned". This method will only remove orphaned objects (package versions, artifacts, and scratch spaces) that have been continually un-used for a period ofcollect_delay
; which defaults to seven days.
Pkg.status
—FunctionPkg.status([pkgs...]; outdated::Bool=false, mode::PackageMode=PKGMODE_PROJECT, diff::Bool=false, compat::Bool=false, extensions::Bool=false, io::IO=stdout)
Print out the status of the project/manifest.
Packages marked with⌃
have new versions that can be installed, e.g. viaPkg.update
. Those marked with⌅
have new versions available, but cannot be installed due to compatibility conflicts with other packages. To see why, set the keyword argumentoutdated=true
.
Settingoutdated=true
will only show packages that are not on the latest version, their maximum version and why they are not on the latest version (either due to other packages holding them back due to compatibility constraints, or due to compatibility in the project file). As an example, a status output like:
pkg> Pkg.status(; outdated=true)Status `Manifest.toml`⌃ [a8cc5b0e] Crayons v2.0.0 [<v3.0.0], (<v4.0.4)⌅ [b8a86587] NearestNeighbors v0.4.8 (<v0.4.9) [compat]⌅ [2ab3a3ac] LogExpFunctions v0.2.5 (<v0.3.0): SpecialFunctions
means that the latest version of Crayons is 4.0.4 but the latest version compatible with the[compat]
section in the current project is 3.0.0. The latest version of NearestNeighbors is 0.4.9 but due to compat constrains in the project it is held back to 0.4.8. The latest version of LogExpFunctions is 0.3.0 but SpecialFunctions is holding it back to 0.2.5.
Ifmode
isPKGMODE_PROJECT
, print out status only about the packages that are in the project (explicitly added). Ifmode
isPKGMODE_MANIFEST
, print status also about those in the manifest (recursive dependencies). If there are any packages listed as arguments, the output will be limited to those packages.
Settingext=true
will show dependencies with extensions and what extension dependencies of those that are currently loaded.
Settingdiff=true
will, if the environment is in a git repository, limit the output to the difference as compared to the last git commit.
SeePkg.project
andPkg.dependencies
to get the project/manifest status as a Julia object instead of printing it.
Pkg.compat
—FunctionPkg.compat()
Interactively edit the [compat] entries within the current Project.
Pkg.compat(pkg::String, compat::String)
Set the [compat] string for the given package within the current Project.
SeeCompatibility for more information on the project [compat] section.
Pkg.precompile
—FunctionPkg.precompile(; strict::Bool=false, timing::Bool=false)Pkg.precompile(pkg; strict::Bool=false, timing::Bool=false)Pkg.precompile(pkgs; strict::Bool=false, timing::Bool=false)
Precompile all or specific dependencies of the project in parallel.
Settiming=true
to show the duration of the precompilation of each dependency.
Errors will only throw when precompiling the top-level dependencies, given that not all manifest dependencies may be loaded by the top-level dependencies on the given system. This can be overridden to make errors in all dependencies throw by setting the kwargstrict
totrue
This method is called automatically after any Pkg action that changes the manifest. Any packages that have previously errored during precompilation won't be retried in auto mode until they have changed. To disable automatic precompilation setENV["JULIA_PKG_PRECOMPILE_AUTO"]=0
. To manually control the number of tasks used setENV["JULIA_NUM_PRECOMPILE_TASKS"]
.
Examples
Pkg.precompile()Pkg.precompile("Foo")Pkg.precompile(["Foo", "Bar"])
Pkg.offline
—FunctionPkg.offline(b::Bool=true)
Enable (b=true
) or disable (b=false
) offline mode.
In offline mode Pkg tries to do as much as possible without connecting to internet. For example, when adding a package Pkg only considers versions that are already downloaded in version resolution.
To work in offline mode across Julia sessions you can set the environment variableJULIA_PKG_OFFLINE
to"true"
.
Pkg.why
—FunctionPkg.why(pkg::Union{String, Vector{String}})Pkg.why(pkg::Union{PackageSpec, Vector{PackageSpec}})
Show the reason why this package is in the manifest. The output is all the different ways to reach the package through the dependency graph starting from the dependencies.
Pkg.dependencies
—FunctionPkg.dependencies()::Dict{UUID, PackageInfo}
This feature is considered experimental.
Query the dependency graph of the active project. The result is aDict
that maps a package UUID to aPackageInfo
struct representing the dependency (a package).
PackageInfo
fields
Field | Description |
---|---|
name | The name of the package |
version | The version of the package (this isNothing for stdlibs) |
tree_hash | A file hash of the package directory tree |
is_direct_dep | The package is a direct dependency |
is_pinned | Whether a package is pinned |
is_tracking_path | Whether a package is tracking a path |
is_tracking_repo | Whether a package is tracking a repository |
is_tracking_registry | Whether a package is being tracked by registry i.e. not by path nor by repository |
git_revision | The git revision when tracking by repository |
git_source | The git source when tracking by repository |
source | The directory containing the source code for that package |
dependencies | The dependencies of that package as a vector of UUIDs |
Pkg.respect_sysimage_versions
—FunctionPkg.respect_sysimage_versions(b::Bool=true)
Enable (b=true
) or disable (b=false
) respecting versions that are in the sysimage (enabled by default).
If this option is enabled, Pkg will only install packages that have been put into the sysimage (e.g. via PackageCompiler) at the version of the package in the sysimage. Also, trying to add a package at a URL ordevelop
a package that is in the sysimage will error.
Pkg.project
—FunctionPkg.project()::ProjectInfo
This feature is considered experimental.
Request aProjectInfo
struct which contains information about the active project.
ProjectInfo
fields
Field | Description |
---|---|
name | The project's name |
uuid | The project's UUID |
version | The project's version |
ispackage | Whether the project is a package (has a name and uuid) |
dependencies | The project's direct dependencies as aDict which maps dependency name to dependency UUID |
path | The location of the project file which defines the active project |
Pkg.undo
—Functionundo()
Undoes the latest change to the active project. Only states in the current session are stored, up to a maximum of 50 states.
See also:redo
.
Pkg.redo
—Functionredo()
Redoes the changes from the latestundo
.
Pkg.setprotocol!
—Functionsetprotocol!(; domain::AbstractString = "github.com", protocol::Union{Nothing, AbstractString}=nothing)
Set the protocol used to access hosted packages whenadd
ing a url ordevelop
ing a package. Defaults to delegating the choice to the package developer (protocol === nothing
). Other choices forprotocol
are"https"
or"git"
.
Examples
julia> Pkg.setprotocol!(domain = "github.com", protocol = "ssh")julia> Pkg.setprotocol!(domain = "gitlab.mycompany.com")
Pkg.PackageSpec
—TypePackageSpec(name::String, [uuid::UUID, version::VersionNumber])PackageSpec(; name, url, path, subdir, rev, version, mode, level)
APackageSpec
is a representation of a package with various metadata. This includes:
name
of the package.uuid
.version
(for example when adding a package). When upgrading, can also be an instance of the enumUpgradeLevel
. If the version is given as aString
this means that unspecified versions are "free", for exampleversion="0.5"
allows any version0.5.x
to be installed. If given as aVersionNumber
, the exact version is used, for exampleversion=v"0.5.3"
.url
and an optional gitrev
ision.rev
can be a branch name or a git commit SHA1.path
. This is equivalent to using theurl
argument but can be more descriptive.subdir
which can be used when adding a package that is not in the root of a repository.Most functions in Pkg take aVector
ofPackageSpec
and do the operation on all the packages in the vector.
Many functions that take aPackageSpec
or aVector{PackageSpec}
can be called with a more concise notation withNamedTuple
s. For example,Pkg.add
can be called either as the explicit or concise versions as:
Explicit | Concise |
---|---|
Pkg.add(PackageSpec(name="Package")) | Pkg.add(name = "Package") |
Pkg.add(PackageSpec(url="www.myhost.com/MyPkg"))) | Pkg.add(url="www.myhost.com/MyPkg") |
Pkg.add([PackageSpec(name="Package"), PackageSpec(path="/MyPkg"]) | Pkg.add([(;name="Package"), (;path="/MyPkg")]) |
Below is a comparison between the REPL mode and the functional API:
REPL | API |
---|---|
Package | PackageSpec("Package") |
Package@0.2 | PackageSpec(name="Package", version="0.2") |
- | PackageSpec(name="Package", version=v"0.2.1") |
Package=a67d... | PackageSpec(name="Package", uuid="a67d...") |
Package#master | PackageSpec(name="Package", rev="master") |
local/path#feature | PackageSpec(path="local/path"; rev="feature") |
www.mypkg.com | PackageSpec(url="www.mypkg.com") |
--major Package | PackageSpec(name="Package", version=UPLEVEL_MAJOR) |
Pkg.PackageMode
—TypePackageMode
An enum with the instances
PKGMODE_MANIFEST
PKGMODE_PROJECT
Determines if operations should be made on a project or manifest level. Used as an argument toPkg.rm
,Pkg.update
andPkg.status
.
Pkg.UpgradeLevel
—TypeUpgradeLevel
An enum with the instances
UPLEVEL_FIXED
UPLEVEL_PATCH
UPLEVEL_MINOR
UPLEVEL_MAJOR
Determines how much a package is allowed to be updated. Used as an argument toPackageSpec
or as an argument toPkg.update
.
The functional API for registries usesRegistrySpec
s, similar toPackageSpec
.
Pkg.RegistrySpec
—TypeRegistrySpec(name::String)RegistrySpec(; name, uuid, url, path)
ARegistrySpec
is a representation of a registry with various metadata, much likePackageSpec
. This includes:
name
of the registry.uuid
.url
to the registry.path
.Most registry functions in Pkg take aVector
ofRegistrySpec
and do the operation on all the registries in the vector.
Many functions that take aRegistrySpec
can be called with a more concise notation with keyword arguments. For example,Pkg.Registry.add
can be called either as the explicit or concise versions as:
Explicit | Concise |
---|---|
Pkg.Registry.add(RegistrySpec(name="General")) | Pkg.Registry.add(name = "General") |
Pkg.Registry.add(RegistrySpec(url="https://github.com/JuliaRegistries/General.git"))) | Pkg.Registry.add(url = "https://github.com/JuliaRegistries/General.git") |
Below is a comparison between the REPL mode and the functional API::
REPL | API |
---|---|
MyRegistry | RegistrySpec("MyRegistry") |
MyRegistry=a67d... | RegistrySpec(name="MyRegistry", uuid="a67d...") |
local/path | RegistrySpec(path="local/path") |
www.myregistry.com | RegistrySpec(url="www.myregistry.com") |
Pkg.Registry.add
—FunctionPkg.Registry.add(registry::RegistrySpec)
Add new package registries.
The no-argumentPkg.Registry.add()
will install the default registries.
Examples
Pkg.Registry.add("General")Pkg.Registry.add(uuid = "23338594-aafe-5451-b93e-139f81909106")Pkg.Registry.add(url = "https://github.com/JuliaRegistries/General.git")
Pkg.Registry.rm
—FunctionPkg.Registry.rm(registry::String)Pkg.Registry.rm(registry::RegistrySpec)
Remove registries.
Examples
Pkg.Registry.rm("General")Pkg.Registry.rm(uuid = "23338594-aafe-5451-b93e-139f81909106")
Pkg.Registry.update
—FunctionPkg.Registry.update()Pkg.Registry.update(registry::RegistrySpec)Pkg.Registry.update(registry::Vector{RegistrySpec})
Update registries. If no registries are given, update all available registries.
Examples
Pkg.Registry.update()Pkg.Registry.update("General")Pkg.Registry.update(uuid = "23338594-aafe-5451-b93e-139f81909106")
Pkg.Registry.status
—FunctionPkg.Registry.status()
Display information about available registries.
Examples
Pkg.Registry.status()
Pkg.Artifacts.create_artifact
—Functioncreate_artifact(f::Function)
Creates a new artifact by runningf(artifact_path)
, hashing the result, and moving it to the artifact store (~/.julia/artifacts
on a typical installation). Returns the identifying tree hash of this artifact.
Pkg.Artifacts.remove_artifact
—Functionremove_artifact(hash::SHA1; honor_overrides::Bool=false)
Removes the given artifact (identified by its SHA1 git tree hash) from disk. Note that if an artifact is installed in multiple depots, it will be removed from all of them. If an overridden artifact is requested for removal, it will be silently ignored; this method will never attempt to remove an overridden artifact.
In general, we recommend that you usePkg.gc()
to manage artifact installations and do not useremove_artifact()
directly, as it can be difficult to know if an artifact is being used by another package.
Pkg.Artifacts.verify_artifact
—Functionverify_artifact(hash::SHA1; honor_overrides::Bool=false)
Verifies that the given artifact (identified by its SHA1 git tree hash) is installed on- disk, and retains its integrity. If the given artifact is overridden, skips the verification unlesshonor_overrides
is set totrue
.
Pkg.Artifacts.bind_artifact!
—Functionbind_artifact!(artifacts_toml::String, name::String, hash::SHA1; platform::Union{AbstractPlatform,Nothing} = nothing, download_info::Union{Vector{Tuple},Nothing} = nothing, lazy::Bool = false, force::Bool = false)
Writes a mapping ofname
->hash
within the given(Julia)Artifacts.toml
file. Ifplatform
is notnothing
, this artifact is marked as platform-specific, and will be a multi-mapping. It is valid to bind multiple artifacts with the same name, but differentplatform
s andhash
'es within the sameartifacts_toml
. Ifforce
is set totrue
, this will overwrite a pre-existant mapping, otherwise an error is raised.
download_info
is an optional vector that contains tuples of URLs and a hash. These URLs will be listed as possible locations where this artifact can be obtained. Iflazy
is set totrue
, even if download information is available, this artifact will not be downloaded until it is accessed via theartifact"name"
syntax, orensure_artifact_installed()
is called upon it.
Pkg.Artifacts.unbind_artifact!
—Functionunbind_artifact!(artifacts_toml::String, name::String; platform = nothing)
Unbind the givenname
from an(Julia)Artifacts.toml
file. Silently fails if no such binding exists within the file.
Pkg.Artifacts.download_artifact
—Functiondownload_artifact(tree_hash::SHA1, tarball_url::String, tarball_hash::String; verbose::Bool = false, io::IO=stderr)
Download/install an artifact into the artifact store. Returnstrue
on success, returns an error object on failure.
Pkg.Artifacts.ensure_artifact_installed
—Functionensure_artifact_installed(name::String, artifacts_toml::String; platform::AbstractPlatform = HostPlatform(), pkg_uuid::Union{Base.UUID,Nothing}=nothing, verbose::Bool = false, quiet_download::Bool = false, io::IO=stderr)
Ensures an artifact is installed, downloading it via the download information stored inartifacts_toml
if necessary. Throws an error if unable to install.
Pkg.Artifacts.ensure_all_artifacts_installed
—Functionensure_all_artifacts_installed(artifacts_toml::String; platform = HostPlatform(), pkg_uuid = nothing, include_lazy = false, verbose = false, quiet_download = false, io::IO=stderr)
Installs all non-lazy artifacts from a given(Julia)Artifacts.toml
file.package_uuid
must be provided to properly support overrides fromOverrides.toml
entries in depots.
Ifinclude_lazy
is set totrue
, then lazy packages will be installed as well.
This function is deprecated and should be replaced with the following snippet:
artifacts = select_downloadable_artifacts(artifacts_toml; platform, include_lazy)for name in keys(artifacts) ensure_artifact_installed(name, artifacts[name], artifacts_toml; platform=platform)end
Pkg.Artifacts.archive_artifact
—Functionarchive_artifact(hash::SHA1, tarball_path::String; honor_overrides::Bool=false)
Archive an artifact into a tarball stored attarball_path
, returns the SHA256 of the resultant tarball as a hexadecimal string. Throws an error if the artifact does not exist. If the artifact is overridden, throws an error unlesshonor_overrides
is set.
Settings
This document was generated withDocumenter.jl version 1.14.1 onSunday 13 July 2025. Using Julia version 1.11.6.