Skip to content

Building M2

Mahrud Sayrafi edited this page Jun 20, 2026 · 5 revisions

Building M2 (using dependencies from Homebrew)

Building M2 from git repository

You can use brew to install every build dependency when compiling Macaulay2 from source.

brew tap Macaulay2/tap
brew trust Macaulay2/tap
brew install ccache $(brew deps --1 --include-build Macaulay2/tap/M2)

OPT_PREFIX=$(brew deps --1 --include-build macaulay2/tap/M2 | \
	cut -d'/' -f-1 | sed "s|^|$HOMEBREW_PREFIX/opt/|" | paste -sd';' -)

cd M2/BUILD/build
cmake -GNinja -S ../.. -B . \
      -DBUILD_NATIVE=OFF \
      -DCMAKE_PREFIX_PATH=$OPT_PREFIX \
      -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_INSTALL_PREFIX=/usr

ninja M2-core

Possibly relevant issues:

Building M2 from brew formula

If you are having issues with slow brew builds from source or errors while generating the documentation, you can instead try building the upstream version of Macaulay2 with:

brew install Macaulay2/tap/M2 --HEAD

then installing the package documentation files with:

brew install Macaulay2/tap/Macaulay2-common

Note: the documentation may be outdated. If this is your only option to access Macaulay2, ask a maintainer to update the documentation.

Clone this wiki locally