Skip to content

Installing P

If you want to use older P version 1.x.x, please use the installation steps here

P is built to be cross-platform and can be used on MacOS, Linux, and Windows. We provide a step-by-step guide for installing P along with the required dependencies.

After each step, please use the troubleshooting check to ensure that each installation step succeeded.

[Step 1] Install .Net Core SDK

The P compiler is implemented in C# and hence the tool chain requires dotnet. P currently uses the specific version of .Net SDK 8.0.

Installing .Net SDK on MacOS using Homebrew (details)

brew tap isen-ng/dotnet-sdk-versions
brew install --cask dotnet-sdk8-0-200

Dont have Homebrew? 🙃 Install manually using the installer for x64 or Arm64.

Installing .Net SDK on Ubuntu (details)

wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt update && sudo apt install -y dotnet-sdk-8.0

Installing .Net SDK on Amazon Linux 2 (details)

wget https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh
chmod +x dotnet-install.sh
./dotnet-install.sh  -c 8.0 -i ~/.dotnet

# If using a bash shell, replace .zshrc with .bashrc in the below commands
echo 'PATH=$HOME/.dotnet:$HOME/.dotnet/tools:$PATH' >> ~/.zshrc
echo 'export PATH' >> ~/.zshrc
source ~/.zshrc

sudo mkdir /usr/share/dotnet/
sudo cp -r ~/.dotnet/* /usr/share/dotnet/

Installing .Net SDK on Windows using the installer for x64 or Arm64

Troubleshoot: Confirm that dotnet is correctly installed on your machine.
dotnet --list-sdks

You must see an SDK with 8.0.* dotnet version installed. If you get dotnet command not found error, mostly likely, you need to add the path to dotnet in your PATH.

Useful resources:

[Step 2] Install Java Runtime

The P compiler also requires Java (java version 11 or higher).

Installing Java on MacOS using Homebrew (details)

brew install java
Dont have Homebrew? Directly use installer.

Installing Java on Ubuntu (details)

sudo apt install -y default-jre

Installing Java 17 on Amazon Linux (you can use any version of java >= 11)

sudo yum install -y java-17-amazon-corretto

Installing Java on Windows (details)

Troubleshoot: Confirm that java is correctly installed on your machine.
java -version

If you get java command not found error, mostly likely, you need to add the path to java in your PATH.

[Step 3] Install P tool

Finally, let's install the P tool as a dotnet tool using the following command:

dotnet tool install --global P
Troubleshoot: Confirm that p is correctly installed on your machine

After installation, run which p and it should show:

which p
/Users/<user>/.dotnet/tools/p
If not, add $HOME/.dotnet/tools to $PATH in your .bash_profile (or equivalent) and try again after restarting the shell. If you are getting the error that the p command is not found, it is most likely that $HOME/.dotnet/tools is not in your PATH.

Updating P Compiler

You can update the version of P compiler by running the following command:

dotnet tool update --global P
  • For developing P programs, we recommend using Peasy.

  • For debugging generated C# code, we recommend using Rider for Mac/Linux or Visual Studio 2019 for Windows.

  • For debugging generated Java code, we recommend using IntelliJ IDEA

Great 😄! You are all set to compile and check your first P program 🎓!