How do I install ripgrep (rg) on Windows?
2 Answers
I've had to start developing on Windows again recently, and have had a hard time figuring this out.
So, here's what I've come up with:
Tested in Windows 10 Pro and Windows 11 Pro.
First, install Git for Windows.
Then, open up the Git Bash terminal which comes with it. You should run all commands below in Git Bash unless stated otherwise.
The super-short, quick answer:
Update 4 Sept. 2024: for an easy, non-admin solution, use scoop instead. See "Option 0" below.
Open Git Bash as an admin, and run:
# install ripgrep
choco install ripgrep
# verify it is now installed
rg --version
If you don't have choco (Chocolatey) installed, you can install it by running this as an admin in PowerShell:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Source: https://chocolatey.org/install
Other, non-admin installation options, and more details, are below:
[No admin privileges required] Option 0: use scoop instead of choco
See my comment on how to install via scoop (instead of choco) in a non-admin PowerShell terminal!:
Note that installing rga (ripgrep-all) also installs rg (ripgrep):
Instructions to install
rgaviascoop
Install
scoop: in a non-admin PowerShell, run:Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-ExpressionSource: https://scoop.sh/
Install
rgaviascoop: in a non-admin PowerShell, run:# Install rga (ripgrep-all) scoop install rga # Install fzf too while we are at it scoop install fzfSource: https://github.com/phiresky/ripgrep-all?tab=readme-ov-file#scoop
Now it works!
Note: to only get rg (ripgrep) and not rga (ripgrep all) nor fzf (fuzzy finder), just run this instead:
scoop install ripgrep
Source: the official ripgrep repository on GitHub: https://github.com/BurntSushi/ripgrep?tab=readme-ov-file#installation
[More versatile, and does not require admin privileges] Option 1: how to manually install ripgrep (or any executable, for that matter) on Windows
This manual process is pretty much the same on Linux or Windows (except that Git for Windows is needed only on Windows), and can be used for any executable file or script.
Go to the ripgrep releases page here, and find the URL of the executable you want from the latest release. For 64-bit Windows, use either the GNU-compiled version (ripgrep-13.0.0-x86_64-pc-windows-gnu.zip), or the MSVC-compiled version (ripgrep-13.0.0-x86_64-pc-windows-msvc.zip). I tested both and they both run fine. Note that the GNU-compiled rg.exe file is larger at around 38.2 MB, however, and the MSVC-compiled rg.exe is about 4.42 MB. I don't know why there is such a huge difference but I'm guessing it's because the MSVSC-compiled version is relying more on existing Windows dynamic libraries already available in the system.
In the instructions below, I used ripgrep-13.0.0-x86_64-pc-windows-msvc.zip. Adapt the instructions accordingly if you use a different file.
# download the latest 64-bit Windows release file of your choosing (GNU or
# MSVC)
curl -LO https://github.com/BurntSushi/ripgrep/releases/download/13.0.0/ripgrep-13.0.0-x86_64-pc-windows-msvc.zip
# unzip it
unzip ripgrep-13.0.0-x86_64-pc-windows-msvc.zip
# create a ~/bin dir to store it
mkdir -p ~/bin
# copy rg.exe into ~/bin
cd ripgrep-13.0.0-x86_64-pc-windows-msvc
cp -i rg.exe ~/bin/
Now, create and edit your ~/.bashrc file:
# Create `~/.bashrc` if it doesn't exist, or just update the access and
# modification time of the file if it does.
touch ~/.bashrc
# Open the file in your editor of choice. Examples:
notepad ~/.bashrc # in Notepad
nano ~/.bashrc # in Nano
subl ~/.bashrc # in Sublime Text
code ~/.bashrc # in Microsoft Visual Studio Code (MS VSCode)
Add this to the bottom of the ~/.bashrc file you just opened (this is borrowed from Ubuntu's default ~/.profile file, which I've put online here):
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
Finally, close and reopen all Git Bash terminals, or run this in all of them that are open:
# re-source your ~/.bashrc file to update your PATH
. ~/.bashrc
Now test to see that rg (ripgrep) works:
# check the version number
rg --version
My run and output is:
$ rg --version
ripgrep 13.0.0 (rev af6b6c543b)
-SIMD -AVX (compiled)
+SIMD +AVX (runtime)
[Easier, but requires admin privileges] Option 2: how to install ripgrep (or other programs) via a package manager such as choco in Windows
Quick summary:
Press your Windows key --> type in "Git Bash" --> right-click your Git Bash shortcut --> click "Run as administrator". In this Git Bash window running as administrator, run the following commands:
# Install ripgrep in Windows.
# See: https://github.com/BurntSushi/ripgrep#installation. Apparently my
# computer already has `choco` installed on it.
choco install ripgrep
# - then follow the on-screen instructions, typing `y` for "yes",
# or `a` for "yes to all", when needed
# verify that ripgrep is installed; I see:
#
# ripgrep 13.0.0 (rev af6b6c543b)
# -SIMD -AVX (compiled)
# +SIMD +AVX (runtime)
#
rg --version
While you're at it, you might as well install fzf and bat too, since my rgf2.sh script (see: here and the installation instructions at the top of rgf.sh) requires both of those:
choco install fzf # install fuzzy-finder
choco install bat # install colored `cat` ("cat with wings")
Close the Git Bash admin window when done, and go back to using a non-admin Git Bash window.
Details
I am very accustomed to using apt or snap to install programs in Linux Ubuntu.
It turns out that there are 3 popular package managers in Windows too:
- Chocolatey:
choco install ripgrep- Very popular.
- It has some paid versions, but there is also a free (as in freedom) and open source, and no-cost, version for both individuals and companies/organizations as well. See: https://chocolatey.org/pricing.
- Looking in my directory at
C:\ProgramData\chocolatey\LICENSE.txt, I see that the open source license they use is the Apache License, Version 2.0, which I believe is a very non-restrictive (generous) license.
- Looking in my directory at
- Scoop:
scoop install ripgrep - Winget (see also here):
winget install BurntSushi.ripgrep.MSVC- This is an official, Microsoft-supported app.
In Git Bash, check to see if you already have these tools installed. I already had choco and winget installed. I'm not sure why or how I already had them installed, but maybe they came with Windows, or with Git for Windows. See if they are installed on your system:
choco --version # I see `1.3.0`
scoop --version # I see: `bash: scoop: command not found`
winget --version # I see: `v1.5.1572`
Let's use Chocolatey to install ripgrep, since I've read it may be the most popular and have the most programs on it.
Install it See: https://chocolatey.org/install.
Run this in your Power Shell only if you do not already have
chocoinstalled:Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))Then, use it:
Open up Git Bash as an administrator, and run:
choco install ripgrep rg --version # check the version to see if it installed correctlyClose the Git Bash admin window when done, and go back to using a non-admin Git Bash window.
References
- I first discovered the 3 main Windows package managers, Chocolatey, Scoop, and Winget here and here.
- My own answer on how to use
curl(the-Lpart of mycurlusage above is required, as GitHub had an HTML 302 redirect for the download link of theripgreprelease)
Going further
To mass search a ton of PDFs at once with ripgrep, install ripgrep-all, or
rga, here: https://github.com/phiresky/ripgrep-allIn short:
choco install ripgrep-allMy comment on how to install via
scoop(instead ofchoco) in a non-admin PowerShell terminal!
navigate to latest releases https://github.com/BurntSushi/ripgrep/releases
Download the 32 or 64 bit version as desired for example I click on https://github.com/BurntSushi/ripgrep/releases/download/14.1.0/ripgrep-14.1.0-i686-pc-windows-msvc.zip and get the 32 bit zip.
Ensure you alter properties to unblock before right click extract. No need to install. but you may want to add a shortcut to run a cmd in that directory.
Now you have the RG.EXE file unpacked simply run rg -h to see the help screen.
You can write a self installer
ripgrep.cmd called from elsewhere can run rg.exe with parameters (bit of overkill since you can call RG.exe itself, but allows for other customisation). And if not already installed then download and unpack into same folder. RipGrep.cmd
@echo off
set "Ver=14.1.0"
if not exist "%~dp0rg.exe" goto download
"%~dp0rg.exe" %*
pause & exit /b
:download
echo downloading
REM current 32 bit version from https://github.com/BurntSushi/ripgrep/releases (exclude the .zip)
REM replace i686 with x86_64 for 64bit
set "RGver=ripgrep-%Ver%-i686-pc-windows-msvc"
pause
cd /d "%~dp0"
curl -LO https://github.com/BurntSushi/ripgrep/releases/download/%Ver%/%RGver%.zip
tar -xf %RGver%.zip
move %RGver%\*.* "%~dp0"
move %RGver%\doc "%~dp0doc"
move %RGver%\complete "%~dp0complete"
rd %RGver%
echo all down
-
Good addition. Upvoted. It's good to see different ways. Coming from Linux, installing development software on Windows sometimes feels daunting. Commented May 2 at 22:09

