Vendoring is the practice of copying the source code or packages of third-party dependencies into a project’s own repository, usually into a directory named vendor, so that builds use those stored copies instead of downloading them from a package registry. In the Software subject area of installation & packages, the copied code is called vendored dependencies, and the project becomes self-contained with respect to those libraries.
Vendoring trades convenience for control. It guarantees reproducible, offline builds and protects against packages disappearing from a registry, but it moves the burden of updating and patching those copies onto the project that vendors them.
How vendoring works
Vendoring places a complete copy of each dependency inside the project tree and makes the build tool resolve imports from that copy first. The copy is committed to version control together with the application code, so anyone who checks out a given commit gets exactly the same dependency code that the original developers built and tested.
A typical workflow has four steps:
- Declare dependencies in a package manifest and pin versions in a dependency lock file.
- Run the vendoring command, which downloads the resolved versions, including transitive dependencies, into the vendor directory.
- Commit the vendor directory so the repository contains every file needed for the build.
- Build in vendor mode, which tells the compiler or package manager to ignore the network and read only local copies.
Some ecosystems support vendoring directly in their tooling, while others rely on conventions or manual copying. The following table summarizes common mechanisms.
| Ecosystem | Mechanism | Notes |
|---|---|---|
| Go | go mod vendor and a vendor directory | Used automatically when present since Go 1.14 |
| Rust | cargo vendor | Requires a source replacement entry in the Cargo configuration |
| PHP | Composer vendor directory | Often generated, sometimes committed for deployment |
| JavaScript | Committed node_modules or bundled dependencies | Large and platform-sensitive, rarely recommended |
| Python | Copied packages in a private namespace | pip itself ships its dependencies in a _vendor package |
| C and C++ | Copied sources, Git submodules or subtrees | Common because no universal package manager exists |
Why teams vendor dependencies
Teams vendor dependencies chiefly to gain independence from external infrastructure. A build that reads only local files cannot fail because a registry is down, a network is restricted, or a maintainer has deleted or yanked a package version.
- Reproducibility: the same commit always produces a build with identical dependency code, which supports audits and regulated releases.
- Air-gapped environments: defense, industrial and some financial systems build without internet access, so dependencies must be present locally.
- Supply chain review: every line of third-party code is visible in code review, so unexpected changes during an update show up in the diff.
- Local patching: a team can apply an urgent fix to a dependency before the upstream project releases it.
- Isolation for tools: utilities such as pip vendor their own libraries to avoid conflicts with packages installed in the user’s environment.
Vendoring compared with other dependency strategies
Vendoring is one of several ways to make dependency resolution predictable, and it is often confused with version pinning and lock files. Pinning fixes which version is downloaded; vendoring removes the download altogether. The table below compares the main strategies.
| Strategy | What is stored in the repository | Network needed at build | Main weakness |
|---|---|---|---|
| Vendoring | Full dependency source code | No | Repository size and manual updates |
| Lock file only | Exact versions and checksums | Yes | Depends on registry availability |
| Private registry mirror | Nothing extra | Yes, internal only | Requires infrastructure to operate |
| Git submodules | References to external commits | Yes, at checkout | Fragile workflows and broken links |
| System packages | Nothing extra | No, if preinstalled | Versions differ across distributions |
Many organizations now prefer a lock file combined with an internal mirror, which offers most of the reproducibility of vendoring without inflating every repository. Vendoring remains the simplest option for small teams and for projects that must build anywhere without configuration.
Costs, risks and common mistakes
The central risk of vendoring is stale code with known vulnerabilities. A vendored copy does not receive security fixes automatically, and scanners that read only manifests may miss vendored libraries, especially when files were copied by hand without metadata.
| Problem | Cause | Remedy |
|---|---|---|
| Unpatched vulnerabilities | Copies never updated | Scheduled updates and software composition analysis |
| Silent local modifications | Edits made directly in the vendor directory | Keep patches as separate files and reapply them |
| Repository bloat | Large dependency trees committed | Vendor only what the build requires |
| License violations | License files dropped during copying | Preserve license texts and record them in an SBOM |
| Duplicate library versions | Several components vendor the same library | Consolidate through dependency resolution |
Linux distributions such as Debian discourage embedded code copies in packages for exactly these reasons: a single flaw in a widely vendored library may require patching dozens of packages instead of one shared package. A software bill of materials (SBOM) that lists vendored components is the most reliable way to keep them visible.
When vendoring is the right choice
Vendoring is most appropriate when build reliability outweighs update convenience. It suits deployable applications, firmware, embedded software and tools distributed as single packages, and it is generally a poor fit for reusable libraries, because a library that vendors its dependencies forces those copies onto every consumer.
Projects that vendor successfully treat the vendor directory as generated, reviewed code: they regenerate it only through the official command, review its diff during updates, and run vulnerability scanning against the vendored contents on a regular schedule.
A non-technical view
Most software is built from parts made by other people, and those parts are normally fetched from online catalogs whenever the software is assembled. Vendoring means keeping your own copy of every part on the shelf instead of ordering it each time.
This makes the work dependable: the parts cannot go out of stock, and they are always the same. The downside is that nobody replaces your shelf copies automatically when the maker fixes a defect, so someone must check them regularly.
A concrete example
A company builds control software for industrial equipment in a secure facility with no internet connection. Its Go services depend on about 40 open source modules, so developers run go mod vendor on a connected workstation, review the resulting changes, and transfer the repository into the isolated network.
Builds inside the facility read only the vendor directory, and every release can be rebuilt byte for byte years later. To control the main risk, the team runs a vulnerability scan against the vendored code each month and regenerates the directory when a fix is needed. When a flaw is announced in a compression library, the scan flags the vendored copy within a day, and a patched release reaches production the same week.