Local Library Mods
When working on a project, you often need to modify a library or fix a bug in a dependency. Instead of waiting for upstream to merge your pull request, you can use a local "mod" (a fork or a copy) of the library.
Strategy: Decoupling Build Specs from Machine Paths
The goal of a local library mod is to point your project to a local folder temporarily without modifying the standard dub.json, pnpm-workspace.yaml, or requirements.txt in a way that breaks CI/CD.
1. Ecosystem Solutions
Different languages and package managers provide built-in tools for this.
D (DUB)
Use the add-local command. This registers a local path for a specific package globally (or per-user) on your system.
dub add-local /path/to/your/patched-fork 1.2.3
DUB will prioritize this directory over the online registry for version 1.2.3. Your CI environment will remain unaffected since it doesn’t have this local configuration.
See DUB Local vs Remote Paths for detailed examples.
Node.js (PNPM/NPM)
Use link or Workspaces.
-
PNPM Link:
pnpm link /path/to/other/pkg- This creates a symlink innode_modules. -
Workspaces: If you maintain several interrelated packages, putting them in a
pnpm-workspace.yamlallows them to reference each other by version while resolving to local source files.
2. Languages Without Native Support
Some ecosystems lack a clean "global override" similar to DUB.
-
C/C++: Often relies on manual
include_directoriesandtarget_link_librariesin CMake. Package managers like vcpkg and Conan have "overlay" mechanisms, but they are often more complex to set up than a simple command-line link. -
Rust (Cargo): Relies on
[patch]or[replace]inCargo.toml. Like Go, this is explicit in the file and may require care when committing.
3. Comparison of Modding Capabilities
| Ecosystem | Tool | Persistence | CI Safe? |
|---|---|---|---|
DUB |
|
User-global |
Yes (out-of-band) |
PNPM |
|
node_modules |
Yes (local link) |
Python |
|
Venv-local |
Yes |
Go |
|
go.mod |
Manual care needed |
Cargo |
|
Cargo.toml |
Manual care needed |
|
A robust local modding setup allows developers to flip between "production" and "dev" modes without manual file edits. |