Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » Core » how Macaulay2 finds its files » prefixPath
next | previous | forward | backward | up | index | toc

# prefixPath -- absolute locations of Macaulay2 files

## Description

The absolute location of a Macaulay2 file can be obtained by concatenating three components: (a) the prefix, which is one of the members of the list prefixPath; (b) the relative location of the directory containing the file, as recorded in the hash table Layout; and (c) the base name of the file. The value of prefixPath is used by installPackage when determining how to direct documentation hyperlinks from one package to another.

The initial value of prefixPath contains just the following two optional items. If the variable prefixDirectory was given a non-null value initially or by a -e command line argument, then it will be the last element of prefixPath. If the -q option was not given on the command line used to invoke Macaulay2, then the value of applicationDirectory()|"local/" will be the first element of prefixPath. No attempt is made to synchronize the value of prefixPath with the values of prefixDirectory and of applicationDirectory(), which may change.

When running a newly compiled version of Macaulay2, adding something like -E 'prefixDirectory="/usr/"' to the command line is a good way to direct hyperlinks created by installPackage to the documentation provided by an older copy of Macaulay2 installed with the prefix /usr/, and that, in turn, is easily done within Emacs by the keystroke sequence `C-u f12`, which offers you a chance to edit the command line.

The initial value of prefixPath described above can be overridden by the user's initialization file).

The list prefixPath should be distinguished from the list path, which is used to locate files to be loaded, by functions such as searchPath, load, loadPackage, and needsPackage.

The following example shows the list of places where we might find the source code of a package called Foo after it has been installed by installPackage.

    i1 : stack apply(prefixPath, p -> p | Layout#1#"packages" | "Foo.m2")

    o1 = /usr/share/Macaulay2
         ------------------------------------------------------------------------
         /Foo.m2

This example shows the list of places where we might reasonably find the html file documenting a function named bar in a package called Foo.

    i2 : stack apply(prefixPath, p -> p | replace("PKG","Foo",Layout#1#"packagehtml") | "bar.html")

    o2 = /usr/share/doc/
         ------------------------------------------------------------------------
         Macaulay2/Foo/html/bar.html

This example shows the list of places where we might reasonably find the info file documenting a package called Foo.

    i3 : stack apply(prefixPath, p -> p | Layout#1#"info" | "Foo.info")

    o3 = /usr/share/info/Foo.
         ------------------------------------------------------------------------
         info

## See also

- commandLine -- the command line arguments
- invoking the Macaulay2 program
- applicationDirectory -- the path to the user's application directory
- prefixDirectory -- the prefix directory
- path -- list of directories to look in
- searchPath -- search a path for a file
- load -- read Macaulay2 commands
- loadPackage -- load a package
- needsPackage -- load a package if not already loaded

## For the programmer

The object prefixPath is a list.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Macaulay2Doc/ov_system.m2:1955:0.