diff --git a/docs/nargo/0_nargo_installation.md b/docs/nargo/0_nargo_installation.md index 23957ce..674a9a5 100644 --- a/docs/nargo/0_nargo_installation.md +++ b/docs/nargo/0_nargo_installation.md @@ -7,93 +7,112 @@ description: keywords: [Nargo, command line tool, Noir programs, installation guide, how to use Nargo] --- -# Nargo +# Installation -`nargo` is a command line tool for interacting with Noir programs (e.g. compiling, proving, -verifying and more). +We'll download Nargo through `noirup`, a command line tool for managing Noir versions and associated tools. You'll need an internet connection for the download. -Alternatively, the interactions can also be performed in [TypeScript](../getting_started/typescript.md). +> Note: `noirup` currently only supports Linux and macOS. If you're using Windows, please see the section TODO -## Installation +Optionally you can also install [Noir VS Code extension] for syntax highlighting. -There are two approaches to install Nargo: +## Installing `noirup` on Linux or macOS -- [Option 1: Binaries](#option-1-binaries) -- [Option 2: Compile from Source](#option-2-compile-from-source) +If you’re using Linux or macOS, open a terminal and enter the following command: -Optionally you can also install [Noir VS Code extension] for syntax highlighting. +```bash +curl -L https://github.com/noir-lang/noirup/releases/download/v0.1.1/noirup | bash +``` + +The command downloads a script and starts the installation of the `noirup` tool. If the install is successful, the following line will appear: + +``` +Detected your preferred shell is bash and added noirup to PATH. Run 'source /home/user/.bashrc' or start a new terminal session to use noirup. +Then, simply run 'noirup' to install Nargo. +``` + +The installation of `noirup` can be verified by running the command + +```bash +$ noirup --help +The installer for Nargo. +Update or revert to a specific Nargo version with ease. +USAGE: + noirup +OPTIONS: + -h, --help Print help information + -v, --version Install a specific version + -b, --branch Install a specific branch + -P, --pr Install a specific Pull Request + -C, --commit Install a specific commit + -r, --repo Install from a remote GitHub repo (uses default branch if no other options are set) + -p, --path Install a local repository +``` -### Option 1: Binaries +## Installing Nargo -#### Step 1 +Once `noirup` has been installed there are two approaches of installing Nargo. Either installing one of the prebuilt binaries distributed by the Noir team or building from source. -Paste and run the following in the terminal to extract and install the binary: +Prebuilt binaries are much easier to install however the backend runs within WASM which impacts performance. Building from source runs the backend natively and so is recommended in performance critical scenarios. -> **macOS / Linux:** If you are prompted with `Permission denied` when running commands, prepend -> `sudo` and re-run it. +## Prebuilt Binaries -##### macOS (Apple Silicon) +Noirup allows installation of prebuilt binaries for stable releases of Noir. For example, you can install the `0.3.2` release of Nargo by running the command ```bash -mkdir -p $HOME/.nargo/bin && \ -curl -o $HOME/.nargo/bin/nargo-aarch64-apple-darwin.tar.gz -L https://github.com/noir-lang/noir/releases/download/nightly/nargo-aarch64-apple-darwin.tar.gz && \ -tar -xvf $HOME/.nargo/bin/nargo-aarch64-apple-darwin.tar.gz -C $HOME/.nargo/bin/ && \ -echo '\nexport PATH=$PATH:$HOME/.nargo/bin' >> ~/.zshrc && \ -source ~/.zshrc +noirup -v 0.3.2 ``` -##### macOS (Intel) +See [GitHub Releases](https://github.com/noir-lang/noir/releases/) to see other versions which can be installed. + +### Updating Nargo + +Once Nargo is installed via `noirup`, updating to a newly released version is easy. From your shell, run the same command again with the version of Nargo you wish to install. ```bash -mkdir -p $HOME/.nargo/bin && \ -curl -o $HOME/.nargo/bin/nargo-x86_64-apple-darwin.tar.gz -L https://github.com/noir-lang/noir/releases/download/nightly/nargo-x86_64-apple-darwin.tar.gz && \ -tar -xvf $HOME/.nargo/bin/nargo-x86_64-apple-darwin.tar.gz -C $HOME/.nargo/bin/ && \ -echo '\nexport PATH=$PATH:$HOME/.nargo/bin' >> ~/.zshrc && \ -source ~/.zshrc +noirup -v 0.4.0 ``` -##### Windows (PowerShell) +## Compilation from Source -Open PowerShell as Administrator and run: +### Installing dependencies -```sh -mkdir -f -p "$env:USERPROFILE\.nargo\bin\"; ` -Invoke-RestMethod -Method Get -Uri https://github.com/noir-lang/noir/releases/download/nightly/nargo-x86_64-pc-windows-msvc.zip -Outfile "$env:USERPROFILE\.nargo\bin\nargo-x86_64-pc-windows-msvc.zip"; ` -Expand-Archive -Path "$env:USERPROFILE\.nargo\bin\nargo-x86_64-pc-windows-msvc.zip" -DestinationPath "$env:USERPROFILE\.nargo\bin\"; ` -$Reg = "Registry::HKLM\System\CurrentControlSet\Control\Session Manager\Environment"; ` -$OldPath = (Get-ItemProperty -Path "$Reg" -Name PATH).Path; ` -$NewPath = $OldPath + ’;’ + "$env:USERPROFILE\.nargo\bin\"; ` -Set-ItemProperty -Path "$Reg" -Name PATH –Value "$NewPath"; ` -$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") +In order to compile Nargo `noirup` requires access to [Git] and [Rust] so these must be installed. As well as the dependencies for Nargo you must install the dependencies for the [Barretenberg] proving backend. + +#### macOS + +Installing through [Homebrew] is recommended: + +```bash +brew install cmake llvm libomp ``` -##### Linux (Bash) +#### Ubuntu (Linux) -See [GitHub Releases](https://github.com/noir-lang/noir/releases/tag/nightly) for additional -platform specific binaries. +```bash +sudo apt update && sudo apt install clang lld cmake libomp-dev +``` + +Other variants of Linux will need to adjust the commands for their package manager. + +### Compilation + +Once all of Nargo's and Barretenberg's dependencies are installed, you can compile Nargo by calling ```bash -mkdir -p $HOME/.nargo/bin && \ -curl -o $HOME/.nargo/bin/nargo-x86_64-unknown-linux-gnu.tar.gz -L https://github.com/noir-lang/noir/releases/download/nightly/nargo-x86_64-unknown-linux-gnu.tar.gz && \ -tar -xvf $HOME/.nargo/bin/nargo-x86_64-unknown-linux-gnu.tar.gz -C $HOME/.nargo/bin/ && \ -echo '\nexport PATH=$PATH:$HOME/.nargo/bin' >> ~/.bashrc && \ -source ~/.bashrc +noirup -c 29b1f7d # Commit hash of 0.3.2 release ``` -#### Step 2 +### Verifying installation Check if the installation was successful by running `nargo --help`. -> **macOS:** If you are prompted with an OS alert, right-click and open the _nargo_ executable from -> Finder. Close the new terminal popped up and `nargo` should now be accessible. +> **macOS:** If you are prompted with an OS alert, right-click and open the _nargo_ executable from Finder. Close the new terminal popped up and `nargo` should now be accessible. -For a successful installation, you should see something similar to the following after running the -command: +For a successful installation, you should see something similar to the following after running the command: ``` $ nargo --help - -Noir's package manager +nargo 0.3.2 Usage: nargo @@ -110,99 +129,25 @@ Commands: help Print this message or the help of the given subcommand(s) ``` -### Option 2: Compile from Source - -#### Setup - -1. Install [Git] and [Rust]. - -2. Download Noir's source code from Github by running: - - ```bash - git clone git@github.com:noir-lang/noir.git - ``` - -3. Change directory into the Noir project by running: - - ```bash - cd noir - ``` - -There are then two approaches to proceed, differing in how the proving backend is installed: - -#### Option 2.1: Install Executable with WASM backend - -4. Install Nargo by running: - - ```bash - cargo install --locked --path=crates/nargo --no-default-features --features plonk_bn254_wasm - ``` - -#### Option 2.2: Install Executable with Native Backend - -The [barretenberg] proving backend is written in C++, hence compiling it from source would first -require certain dependencies to be installed. - -4. Install [CMake], [LLVM] and [OpenMP]: - -##### macOS - -Installing through [Homebrew] is recommended: - -```bash -brew install cmake llvm libomp -``` - -##### Ubuntu (Linux) +## Installing on Windows -```bash -sudo apt update && sudo apt install clang lld cmake libomp-dev -``` +While it's not possible to install Nargo using `noirup` on Windows, the Noir team does distribute prebuilt binaries on Windows. -Other variants of Linux will need to adjust the commands for their package manager. - -##### Windows +In order to install the latest version of Nargo, open PowerShell as Administrator and run: ```sh -TBC +mkdir -f -p "$env:USERPROFILE\.nargo\bin\"; ` +Invoke-RestMethod -Method Get -Uri https://github.com/noir-lang/noir/releases/download/nightly/nargo-x86_64-pc-windows-msvc.zip -Outfile "$env:USERPROFILE\.nargo\bin\nargo-x86_64-pc-windows-msvc.zip"; ` +Expand-Archive -Path "$env:USERPROFILE\.nargo\bin\nargo-x86_64-pc-windows-msvc.zip" -DestinationPath "$env:USERPROFILE\.nargo\bin\"; ` +$Reg = "Registry::HKLM\System\CurrentControlSet\Control\Session Manager\Environment"; ` +$OldPath = (Get-ItemProperty -Path "$Reg" -Name PATH).Path; ` +$NewPath = $OldPath + ’;’ + "$env:USERPROFILE\.nargo\bin\"; ` +Set-ItemProperty -Path "$Reg" -Name PATH –Value "$NewPath"; ` +$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") ``` -5. Install Nargo by running: - - ```bash - cargo install --locked --path=crates/nargo - ``` - -#### Verify Installation - -6. Check if the installation was successful by running `nargo --help`: - - ``` - $ nargo --help - - Noir's package manager - - Usage: nargo - - Commands: - check Checks the constraint system for errors - codegen-verifier Generates a Solidity verifier smart contract for the program - compile Compile the program and its secret execution trace into ACIR format - new Create a new binary project - execute Executes a circuit to calculate its return value - prove Create proof for this program. The proof is returned as a hex encoded string - verify Given a proof and a program, verify whether the proof is valid - test Run the tests for this program - gates Counts the occurrences of different gates in circuit - help Print this message or the help of the given subcommand(s) - ``` - [git]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git [rust]: https://www.rust-lang.org/tools/install -[noir vs code extension]: - https://marketplace.visualstudio.com/items?itemName=noir-lang.noir-programming-language-syntax-highlighter -[barretenberg]: https://github.com/AztecProtocol/aztec-connect/tree/master/barretenberg +[noir vs code extension]: https://marketplace.visualstudio.com/items?itemName=noir-lang.noir-programming-language-syntax-highlighter +[barretenberg]: https://github.com/AztecProtocol/barretenberg [homebrew]: https://brew.sh/ -[cmake]: https://cmake.org/install/ -[llvm]: https://llvm.org/docs/GettingStarted.html -[openmp]: https://openmp.llvm.org/