Linux Error Guide: 'gcc: command not found' — Install a C Compiler and Build Tools
Fix 'gcc: command not found' and 'no acceptable C compiler found in $PATH' by installing build-essential, the Development Tools group, or build-base.
- #linux
- #troubleshooting
- #errors
- #compilers
Stuck on this Linux Admins error? Get the free incident triage checklist
A one-page PDF — the exact steps to isolate, fix, and verify a production error like this one. No spam, unsubscribe anytime.
Overview
Sooner or later, every Linux engineer hits a wall trying to compile something from source, install a Python or Ruby package with a native extension, or build a project inside a lean container image. The build stops cold with one of these:
bash: gcc: command not found
configure: error: no acceptable C compiler found in $PATH
Both messages point at the same underlying condition: there is no working C compiler on the machine — or at least none the shell and the build system can find. The first form comes straight from your shell when you (or a Makefile) invoke gcc and the executable isn’t on PATH. The second comes from an autotools ./configure script, which probes for a compiler before generating a Makefile and aborts when the probe fails.
This guide walks through the root causes, a fast diagnostic workflow, and the exact per-distro commands to install a compiler toolchain correctly.
Symptoms
You will typically see one or more of the following:
- Running
gcc(orcc) directly returnsbash: gcc: command not found. ./configurefails early withno acceptable C compiler found in $PATH.makefails on the first compile line, often asmake: gcc: No such file or directory.pip installof a package with a C extension fails witherror: command 'gcc' failed: No such file or directoryorerror: Microsoft Visual C++...-style messages replaced by a missing-gcccomplaint on Linux.npm installof a package usingnode-gypfails while compiling native addons.- The failure appears only inside a container, CI runner, or freshly provisioned VM, while your workstation builds fine.
Common Root Causes
No toolchain installed. Minimal server and cloud images ship without a compiler to keep the footprint small. gcc, make, and the C headers simply aren’t present.
Minimal or container base image. Images like ubuntu, debian:slim, python:3-slim, and alpine deliberately omit build tools. Anything that compiles native code needs the toolchain added explicitly.
PATH missing /usr/bin. Rare, but a broken shell profile, a stripped-down env, or a misconfigured CI job can drop /usr/bin from PATH, so an installed gcc becomes invisible.
Only clang is installed. Some systems provide clang but not gcc. Autotools defaults to looking for gcc/cc; if only clang exists and cc isn’t symlinked to it, configure may still fail unless you point it at the compiler.
Missing make or development headers. Sometimes gcc exists but make, libc headers (/usr/include), or -dev/-devel packages are absent, so compilation fails partway through rather than at the compiler-lookup stage.
Diagnostic Workflow
Work top to bottom. Each command narrows down whether the compiler is missing, unfindable, or incomplete.
# Is gcc on PATH at all?
which gcc
# Does it run, and which version?
gcc --version
# Is a generic C compiler (cc) available? cc is often a symlink to gcc.
command -v cc
# Confirm PATH actually contains the standard binary dirs.
echo $PATH
# Look for any installed gcc binaries directly on disk.
ls /usr/bin/gcc*
# Debian/Ubuntu: is the meta-package installed?
dpkg -l | grep -i build-essential
# RHEL/Fedora/Rocky/Alma: is gcc installed?
rpm -q gcc
# Debian/Ubuntu: is gcc even available to install, and from where?
apt-cache policy gcc
Interpretation:
which gccprints nothing butls /usr/bin/gcc*shows a binary → this is a PATH problem. Inspectecho $PATHand ensure/usr/binis present.- Both come up empty → the compiler is not installed. Install the toolchain (next section).
gcc --versionworks butmakeis missing → installmakeand the relevant-dev/-develheader packages.command -v ccresolves to clang but autotools still fails → pass./configure CC=clangor install gcc.
Example Root Cause Analysis
A CI pipeline builds a small C library from source. It works locally but fails on a fresh ubuntu:24.04 container step:
$ ./configure
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in '/src':
configure: error: no acceptable C compiler found in $PATH
See 'config.log' for more details
Diagnosis inside the container:
which gcc # (no output)
ls /usr/bin/gcc* # ls: cannot access '/usr/bin/gcc*': No such file or directory
The base image simply has no compiler. The fix is to install the build-essential meta-package, which pulls in gcc, g++, make, and the libc development headers in one shot:
apt-get update && apt-get install -y build-essential
Verify before re-running the build:
gcc --version
# gcc (Ubuntu 13.x) 13.x.x
With the compiler in place, ./configure && make proceeds normally. In a container context, run the same install as a RUN line in the Dockerfile rather than manually, so the fix is reproducible.
Prevention Best Practices
Bake build tools into images. If a CI job or container compiles code, install the toolchain in the Dockerfile (or a prebuilt base image) instead of ad hoc at runtime. This removes flakiness and network dependence during builds.
FROM ubuntu:24.04
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential \
&& rm -rf /var/lib/apt/lists/*
Use multi-stage builds so runtime stays slim. Compile in a builder stage that has the full toolchain, then copy only the resulting artifacts into a minimal runtime image. Your production image stays small and free of compilers.
FROM ubuntu:24.04 AS build
RUN apt-get update && apt-get install -y build-essential
COPY . /src
WORKDIR /src
RUN make
FROM ubuntu:24.04
COPY --from=build /src/myapp /usr/local/bin/myapp
Document toolchain dependencies. State the required build packages in the project README so contributors and pipelines install them consistently.
Pin compiler versions with update-alternatives. When multiple GCC versions coexist, register them and select a default explicitly so builds are deterministic:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 90
sudo update-alternatives --config gcc
Quick Command Reference
# Debian / Ubuntu — meta-package with gcc, g++, make, libc headers
sudo apt update
sudo apt install build-essential
# RHEL / CentOS / Rocky / AlmaLinux — Development Tools group
sudo dnf groupinstall "Development Tools"
# older releases using yum:
sudo yum groupinstall "Development Tools"
# Fedora — same group name
sudo dnf groupinstall "Development Tools"
# or, for just the compiler and make:
sudo dnf install gcc gcc-c++ make
# Alpine — build-base pulls in gcc, g++, make, libc-dev
apk add build-base
# Arch Linux — base-devel group
sudo pacman -S base-devel
# Verify the compiler is now present and on PATH
gcc --version
which gcc
Conclusion
gcc: command not found and configure: error: no acceptable C compiler found in $PATH almost always mean the same thing: no usable C compiler on PATH. Diagnose with which gcc, gcc --version, and echo $PATH to distinguish a missing toolchain from a broken PATH, then install the correct package for your distribution — build-essential on Debian/Ubuntu, the “Development Tools” group on RHEL and Fedora, build-base on Alpine, or base-devel on Arch. For containers and CI, bake the toolchain into your image with a Dockerfile and lean on multi-stage builds to keep runtime images slim. Confirm success with gcc --version and your build will pick up right where it stopped.
Fixed it? Get 500 Linux Admins & DevOps AI prompts — free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.
Did this fix your issue?
Get 500 Battle-Tested DevOps AI Prompts — Free
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.