Install Pact on Linux
You can download and install the Pact programming language and interactive interpreter locally on your local computer as prebuilt binary file from a release archive or build Pact directly from its source code.
Prerequisites
If you are installing Pact 4.x, you should note that this version of Pact requires the z3 theorem prover from Microsoft Research to support formal verification.
Starting with Pact 5, Pact no longer supports formal verification using the z3 theorem prover.
If you are installing Pact 5, or later, you can continue to the Installation instructions.
If you are installing Pact 4.x, you can install and verify the installation of the z3 package on Linux by running the following commands:
sudo apt update
sudo apt install z3
z3 --version
If z3 is installed properly, you should see output similar to the following:
Z3 version 4.13.3 - 64 bit
Installation instructions
To install Pact on Linux:
-
Navigate to the appropriate Pact Releases page:
- Pact Releases to download the latest stable version of Pact 4.x.
- Pact 5 Releases to download the latest version of Pact 5.
-
Download the latest
pact-<version>-linux-<arch>.tar.gzfile for the Linux operating system and architecture you use. -
Open a terminal and extract the downloaded compressed archive by running the following command:
tar -xvzf pact-<version>-linux-<arch>.tar.gz -
Navigate to the extracted directory:
cd pact-<version>-linux-<arch> -
Move the
pactbinary to a directory in your systemPATH, or update yourPATHvariable.For example, to move the
pactbinary from the current working directory to the/usr/local/bindirectory and update thePATH:sudo mv pact /usr/local/bin
export PATH="/usr/local/bin:$PATH" -
Reload the shell configuration.
For example, reload the configuration for the
bashshell by running the following command:source ~/.bashrcReplace
~/.bashrcwith~/.zshrcif you use thezshshell. -
Verify the installation by checking the Pact version:
pact --version -
View usage information for the pact interactive interpreter by running the following command:
pact --helpFor more information about the command-line options, see Pact command-line interpreter. For an introduction to Pact programming and language features, see Pact features and conventions.
Troubleshooting
If you encounter issues, check the following:
-
Check the Pact version and, if Pact, version 4.x, is installed, verify that you have
z3installed.pact --versionThis command should display output similar to the following:
pact version 4.13If the Pact version is 4.x, check for the z3 package by running the following command:
z3 --versionIf
z3is installed correctly, the command should display output similar to the following:Z3 version 4.8.12 - 64 bitIf necessary, install z3 by running the following commands:
sudo apt update
sudo apt install z3
z3 --version -
Verify the
pactbinary can be located and is in a directory included in yourPATHenvironment variable.First check the path to the
pactbinary by running the following command:which pactThis command should display the current path to the
pactbinary. For example:/usr/local/bin/pactIf the command doesn't display the path to the
pactbinary, you should try reinstallingpactfrom the prebuilt release archive or from the source code. If thewhich pactcommand displays the path to thepactbinary, check thePATHenvironment variable to verify the path the the binary is include by running the following command:echo $PATHThis command should display output similar to the following:
/home/pistolas/.nix-profile/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/binThe
$PATHoutput should include the directory where thepactbinary is located. If the PATH environment variable doesn't include the directory, open your shell profile—for example, the~/.bashrcor~/.zshrcfile—in a text editor. Add the following line at the end of the file:export PATH="/path/to/pact-directory:$PATH"Save the shell profile file and exit.
Open a new terminal or reload the shell profile to complete the update.
-
Check Pact GitHub Issues for known issues or to report a problem with installing Pact.