When you run Macaulay2, it has to find and load a sequence of startup files containing code written in the Macaulay2 language. Here is the way it does that.
Its first task is to discover the path to the binary file
M2 that is currently running. On some systems, that information is available from the
/proc file system. Otherwise, it examines the command name you used to run the program, which is provided to it as the argument in position number 0 on the command line. If it's not an absolute path, it searches along the path of directories mentioned in the environment variable PATH until it finds a file with the same name. If the result is a symbolic link, the link is followed. The final result is assumed to be in a directory named "
bin/", and the startup files are located relative to that. The path to the top level directory is stored in the variable
prefixDirectory, which you can examine to see whether it all worked out. For detailed information about the relative location of Macaulay2 files, see
Layout.