Package Manager Functions¶
All package manager functions are defined in the Pkg
module. None of the Pkg
module’s functions are exported;
to use them, you’ll need to prefix each function call with an explicit Pkg.
, e.g. Pkg.status()
or Pkg.dir()
.
dir
() → AbstractString¶Returns the absolute path of the package directory. This defaults to
joinpath(homedir(),".julia","v$(VERSION.major).$(VERSION.minor)")
on all platforms (i.e.~/.julia/v0.4
in UNIX shell syntax). If theJULIA_PKGDIR
environment variable is set, then that path is used in the returned value asjoinpath(ENV["JULIA_PKGDIR"],"v$(VERSION.major).$(VERSION.minor)")
. IfJULIA_PKGDIR
is a relative path, it is interpreted relative to whatever the current working directory is.
dir
(names...) → AbstractStringEquivalent to
normpath(Pkg.dir(),names...)
– i.e. it appends path components to the package directory and normalizes the resulting path. In particular,Pkg.dir(pkg)
returns the path to the packagepkg
.
init
(meta::AbstractString=DEFAULT_META, branch::AbstractString=META_BRANCH)¶Initialize
Pkg.dir()
as a package directory. This will be done automatically when theJULIA_PKGDIR
is not set andPkg.dir()
uses its default value. As part of this process, clones a local METADATA git repository from the site and branch specified by its arguments, which are typically not provided. Explicit (non-default) arguments can be used to support a custom METADATA setup.
resolve
()¶Determines an optimal, consistent set of package versions to install or upgrade to. The optimal set of package versions is based on the contents of
Pkg.dir("REQUIRE")
and the state of installed packages inPkg.dir()
, Packages that are no longer required are moved intoPkg.dir(".trash")
.
edit
()¶Opens
Pkg.dir("REQUIRE")
in the editor specified by theVISUAL
orEDITOR
environment variables; when the editor command returns, it runsPkg.resolve()
to determine and install a new optimal set of installed package versions.
add
(pkg, vers...)¶Add a requirement entry for
pkg
toPkg.dir("REQUIRE")
and callPkg.resolve()
. Ifvers
are given, they must beVersionNumber
objects and they specify acceptable version intervals forpkg
.
rm
(pkg)¶Remove all requirement entries for
pkg
fromPkg.dir("REQUIRE")
and callPkg.resolve()
.
clone
(url[, pkg])¶Clone a package directly from the git URL
url
. The package does not need to be a registered inPkg.dir("METADATA")
. The package repo is cloned by the namepkg
if provided; if not provided,pkg
is determined automatically fromurl
.
clone
(pkg)If
pkg
has a URL registered inPkg.dir("METADATA")
, clone it from that URL on the default branch. The package does not need to have any registered versions.
available
() → Vector{ASCIIString}¶Returns the names of available packages.
available
(pkg) → Vector{VersionNumber}Returns the version numbers available for package
pkg
.
installed
() → Dict{ASCIIString,VersionNumber}¶Returns a dictionary mapping installed package names to the installed version number of each package.
installed
(pkg) → Void | VersionNumberIf
pkg
is installed, return the installed version number, otherwise returnnothing
.
status
()¶Prints out a summary of what packages are installed and what version and state they’re in.
update
()¶Update package the metadata repo – kept in
Pkg.dir("METADATA")
– then update any fixed packages that can safely be pulled from their origin; then callPkg.resolve()
to determine a new optimal set of packages versions.
checkout
(pkg[, branch="master"])¶Checkout the
Pkg.dir(pkg)
repo to the branchbranch
. Defaults to checking out the “master” branch. To go back to using the newest compatible released version, usePkg.free(pkg)
pin
(pkg)¶Pin
pkg
at the current version. To go back to using the newest compatible released version, usePkg.free(pkg)
pin
(pkg, version)Pin
pkg
at registered versionversion
.
free
(pkg)¶Free the package
pkg
to be managed by the package manager again. It callsPkg.resolve()
to determine optimal package versions after. This is an inverse for bothPkg.checkout
andPkg.pin
.You can also supply an iterable collection of package names, e.g.,
Pkg.free(("Pkg1","Pkg2"))
to free multiple packages at once.
build
()¶Run the build scripts for all installed packages in depth-first recursive order.
build
(pkgs...)Run the build script in
deps/build.jl
for each package inpkgs
and all of their dependencies in depth-first recursive order. This is called automatically byPkg.resolve()
on all installed or updated packages.
generate
(pkg, license)¶Generate a new package named
pkg
with one of these license keys:"MIT"
,"BSD"
or"ASL"
. If you want to make a package with a different license, you can edit it afterwards. Generate creates a git repo atPkg.dir(pkg)
for the package and inside itLICENSE.md
,README.md
,REQUIRE
, the julia entrypoint$pkg/src/$pkg.jl
, and Travis and AppVeyor CI configuration files.travis.yml
andappveyor.yml
.
register
(pkg[, url])¶Register
pkg
at the git URLurl
, defaulting to the configured origin URL of the git repoPkg.dir(pkg)
.
tag
(pkg[, ver[, commit]])¶Tag
commit
as versionver
of packagepkg
and create a version entry inMETADATA
. If not provided,commit
defaults to the current commit of thepkg
repo. Ifver
is one of the symbols:patch
,:minor
,:major
the next patch, minor or major version is used. Ifver
is not provided, it defaults to:patch
.
publish
()¶For each new package version tagged in
METADATA
not already published, make sure that the tagged package commits have been pushed to the repo at the registered URL for the package and if they all have, open a pull request toMETADATA
.
test
()¶Run the tests for all installed packages ensuring that each package’s test dependencies are installed for the duration of the test. A package is tested by running its
test/runtests.jl
file and test dependencies are specified intest/REQUIRE
.
test
(pkgs...)Run the tests for each package in
pkgs
ensuring that each package’s test dependencies are installed for the duration of the test. A package is tested by running itstest/runtests.jl
file and test dependencies are specified intest/REQUIRE
.