Navigation

Operators and Keywords

Function List:

C++ API

: pkg command pkg_name
: pkg command option pkg_name
: [out1, …] = pkg (command, … )

Manage or query packages (groups of add-on functions) for Octave.

Different actions are available depending on the value of command and on return arguments.

Available commands:

install

Install named packages. For example,

pkg install image-1.0.0.tar.gz

installs the package found in the file image-1.0.0.tar.gz.

The option variable can contain options that affect the manner in which a package is installed. These options can be one or more of

-nodeps

The package manager will disable dependency checking. With this option it is possible to install a package even when it depends on another package which is not installed on the system. Use this option with care.

-local

A local installation (package available only to current user) is forced, even if the user has system privileges.

-global

A global installation (package available to all users) is forced, even if the user doesn’t normally have system privileges.

-forge

Install a package directly from the Octave-Forge repository. This requires an internet connection and the cURL library.

Security risk: no verification of the package is performed before the installation. There are no signature for packages, or checksums to confirm the correct file was downloaded. It has the same security issues as manually downloading the package from the Octave Forge repository and installing it.

-verbose

The package manager will print the output of all commands as they are performed.

update

Check installed Octave-Forge packages against repository and update any outdated items. This requires an internet connection and the cURL library. Usage:

pkg update
uninstall

Uninstall named packages. For example,

pkg uninstall image

removes the image package from the system. If another installed package depends on the image package an error will be issued. The package can be uninstalled anyway by using the -nodeps option.

load

Add named packages to the path. After loading a package it is possible to use the functions provided by the package. For example,

pkg load image

adds the image package to the path.

unload

Remove named packages from the path. After unloading a package it is no longer possible to use the functions provided by the package.

list

Show the list of currently installed packages. For example,

pkg list

will produce a short report with the package name, version, and installation directory for each installed package. Supply a package name to limit reporting to a particular package. For example:

pkg list image

If a single return argument is requested then pkg returns a cell array where each element is a structure with information on a single package.

installed_packages = pkg ("list")

If two output arguments are requested pkg splits the list of installed packages into those which were installed by the current user, and those which were installed by the system administrator.

[user_packages, system_packages] = pkg ("list")

The "-forge" option lists packages available at the Octave-Forge repository. This requires an internet connection and the cURL library. For example:

oct_forge_pkgs = pkg ("list", "-forge")
describe

Show a short description of installed packages. With the option "-verbose" also list functions provided by the package. For example,

pkg describe -verbose

will describe all installed packages and the functions they provide. Display can be limited to a set of packages:

pkg describe control signal # describe control and signal packages

If one output is requested a cell of structure containing the description and list of functions of each package is returned as output rather than printed on screen:

desc = pkg ("describe", "secs1d", "image")

If any of the requested packages is not installed, pkg returns an error, unless a second output is requested:

[desc, flag] = pkg ("describe", "secs1d", "image")

flag will take one of the values "Not installed", "Loaded", or "Not loaded" for each of the named packages.

prefix

Set the installation prefix directory. For example,

pkg prefix ~/my_octave_packages

sets the installation prefix to ~/my_octave_packages. Packages will be installed in this directory.

It is possible to get the current installation prefix by requesting an output argument. For example:

pfx = pkg ("prefix")

The location in which to install the architecture dependent files can be independently specified with an addition argument. For example:

pkg prefix ~/my_octave_packages ~/my_arch_dep_pkgs
local_list

Set the file in which to look for information on locally installed packages. Locally installed packages are those that are available only to the current user. For example:

pkg local_list ~/.octave_packages

It is possible to get the current value of local_list with the following

pkg local_list
global_list

Set the file in which to look for information on globally installed packages. Globally installed packages are those that are available to all users. For example:

pkg global_list /usr/share/octave/octave_packages

It is possible to get the current value of global_list with the following

pkg global_list
build

Build a binary form of a package or packages. The binary file produced will itself be an Octave package that can be installed normally with pkg. The form of the command to build a binary package is

pkg build builddir image-1.0.0.tar.gz …

where builddir is the name of a directory where the temporary installation will be produced and the binary packages will be found. The options -verbose and -nodeps are respected, while all other options are ignored.

rebuild

Rebuild the package database from the installed directories. This can be used in cases where the package database has been corrupted.

See also: ver, news.

Package: octave