How to fix warning: failed to run 'less' as pager in Git
Git attempts to display command output using a pager program (typically 'less') but cannot find or execute it. This causes Git commands like log, diff, and show to either fail or dump raw output directly to the terminal.
Quick fix
Fixes warning: failed to run 'less' as pager
git config --get core.pager
echo $GIT_PAGER
echo $PAGER- Check which pager Git is trying to use
- Verify the pager command exists
- Install the missing pager (if needed)
- Configure Git to use an available pager
git config --get core.pagerecho $GIT_PAGERecho $PAGERwarning: failed to run 'less' as pager
What this error means
Git uses a pager program to display long command output in a scrollable, readable format. By default, Git tries to use 'less' as its pager for commands like git log, git diff, and git show. When Git cannot find the pager executable in your system PATH, or when the configured pager program doesn't exist, you'll see a pager failure warning. This error typically occurs in minimal environments (Docker containers, CI/CD pipelines, Windows Subsystem for Linux) where 'less' or the configured pager isn't installed, or when Git's pager configuration points to an invalid program or path. Before Git 2.46 (Q3 2024), some code paths would fall back to dumping output directly to stdout, but newer versions fail immediately when the pager cannot be spawned. The pager is controlled by three mechanisms in order of precedence: the GIT_PAGER environment variable, the core.pager Git configuration setting, and finally the PAGER environment variable. If all are unset, Git defaults to 'less' with specific flags (FRSX).
Typical symptoms
- Git commands fail with 'failed to run [pager] as pager' warning
- git log or git diff output dumps directly to terminal instead of opening pager
- Error message mentions 'less: command not found' or 'more: No such file or directory'
- CI/CD pipelines fail when running Git commands that would normally use a pager
- Git commands work with --no-pager flag but fail without it
- Permission denied errors when trying to spawn the pager program
Common causes
- The 'less' command is not installed on the system (common in minimal Docker images)
- Git's core.pager is configured to a program that doesn't exist or isn't in PATH
- GIT_PAGER or PAGER environment variables point to invalid executables
- Incorrect path to pager executable (especially on Windows with MSYS/Git Bash)
- Permission issues preventing Git from executing the pager program
- Corrupted Git configuration file with invalid pager settings
- Using Windows 'more.com' but path not properly quoted in configuration
How to fix "warning: failed to run 'less' as pager"
First, identify what pager Git is configured to use:
git config --get core.pager
echo $GIT_PAGER
echo $PAGERIf core.pager returns a value, that's what Git is trying to execute. If empty, check the environment variables. Git will default to 'less' if nothing is configured.
Check if the pager program is installed and accessible:
# Check if less is installed
which less
less --version
# Or check for more
which more
# On Windows
where less
where moreIf the command is not found, you need to either install it or configure Git to use a different pager.
Install 'less' or another pager on your system:
# Ubuntu/Debian
sudo apt-get update && sudo apt-get install less
# Alpine Linux (common in Docker)
apk add less
# macOS (usually pre-installed, but via Homebrew if needed)
brew install less
# Windows with Chocolatey
choco install lessFor Docker containers, add to your Dockerfile:
RUN apt-get update && apt-get install -y lessIf you can't install 'less', configure Git to use an alternative pager that exists on your system:
# Use 'more' instead (available on most systems)
git config --global core.pager more
# On Windows, use the full path to more.com
git config --global core.pager '"C:\Windows\System32\more.com"'
# On MSYS/Git Bash, use full path to less
git config --add --global core.pager /usr/bin/less
# Use cat (disables paging, shows all output at once)
git config --global core.pager catVerify the change:
git config --get core.pagerIf you don't need paging functionality, you can disable it completely:
# Set pager to empty string (disables paging globally)
git config --global core.pager ''
# Or unset the pager configuration
git config --global --unset core.pager
# Remove all pager settings if multiple exist
git config --global --unset-all core.pagerYou can also disable paging per-command:
# Temporary: use --no-pager flag
git --no-pager log
git --no-pager diff
# Or set environment variable for single command
GIT_PAGER=cat git logIf you have conflicting environment variables, clear or correct them:
# Check current environment variables
env | grep PAGER
# Unset GIT_PAGER if it's causing issues
unset GIT_PAGER
# Or set it to a working pager
export GIT_PAGER=less
# On Ubuntu/systems where PAGER is unset
export PAGER=moreAdd to your shell profile (~/.bashrc, ~/.zshrc) to make permanent:
export PAGER=lessVerify that Git commands now work with the pager:
# Test with a command that uses the pager
git log
git diff HEAD~1
# Should open in pager without errors
# Press 'q' to quit the pagerIf you disabled paging, verify output appears directly in terminal without errors.
Advanced notes
Pager Precedence and Customization
Git determines which pager to use in this order: GIT_PAGER environment variable → core.pager config → PAGER environment variable → DEFAULT_PAGER (less). You can configure different pagers for different Git commands using per-subcommand settings like git config --global pager.diff 'less -FX' while keeping other commands unpaged.
Smart Paging with less -FX
For less version 530+, configure core.pager to less -F (or less -FX for older versions) to automatically exit if output fits on one screen, eliminating unnecessary paging for short output. Git sets the LESS environment variable to 'FRSX' by default if unset (F=quit if one screen, R=raw control chars, S=chop long lines, X=no init).
Docker and CI/CD Considerations
In automated environments where interactive paging isn't needed, disable the pager globally in your Dockerfile or CI configuration: RUN git config --global core.pager cat or use the --no-pager flag in all Git commands. This prevents failures in minimal container images while keeping your local development environment intact.
Windows Path Issues
On Windows, pager paths must be properly quoted if they contain spaces. Use double quotes around the path: git config --global core.pager '"C:\Program Files\Git\usr\bin\less.exe"'. For PowerShell, the quoting requirements may differ from Command Prompt.
Permission and Security Context
Since Git 2.46, pager spawn failures always cause immediate command failure rather than falling back to stdout dumping. This prevents accidental exposure of sensitive information in logs when paging fails. If you encounter permission-denied errors, verify the pager executable has execute permissions and isn't blocked by security policies like SELinux or AppArmor.
Frequently asked questions
- What does "warning: failed to run 'less' as pager" mean?
- Git uses a pager program to display long command output in a scrollable, readable format. By default, Git tries to use 'less' as its pager for commands like git log, git diff, and git show. When Git cannot find the pager executable in your system PATH, or when the configured pager program doesn't exist, you'll see a pager failure warning.
- How do I fix "warning: failed to run 'less' as pager"?
- Git attempts to display command output using a pager program (typically 'less') but cannot find or execute it. This causes Git commands like log, diff, and show to either fail or dump raw output directly to the terminal.
- What causes "warning: failed to run 'less' as pager"?
- The 'less' command is not installed on the system (common in minimal Docker images) Git's core.pager is configured to a program that doesn't exist or isn't in PATH GIT_PAGER or PAGER environment variables point to invalid executables
- Is the "warning: failed to run 'less' as pager" error serious?
- It is a low-severity error — more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- 📚Git Official Documentation
- 📖Git Official Documentation(Official Docs)
- 💬Stack Overflow: Git git-pager-failed(Stack Overflow)
- 🐙Git GitHub Issues(GitHub)