PeaBox Lab › PeaLang › Learn › Chapter 11 › Lesson 3

Part II — Intermediate Development · Chapter 11 · Lesson 3 of 6 · 6 min read

Lesson 3: Local, Git, and Registry Sources

Lesson level: Intermediate

Purpose: Learn how a dependency can be declared from a local path, a Git repository, or a registry, and what each source can and cannot guarantee about reproducibility and trust.

Release note: commands, field names, and syntax in this lesson are illustrative. Verify them against your installed v0.63 release before relying on them.

Learning objectives

By the end of this lesson, you should be able to:

3.1 Why the source matters

A version constraint says which versions are acceptable. The source says where the code comes from. Two packages with the same name and version can differ in content if they come from different places, so the source is part of the dependency identity.

3.2 Local path sources

A local path source points to a directory on disk. It is the fastest way to develop a library and its consumer together. In the running example, order_rules can use a sibling checkout of input_checks while you change both.

[dependencies]
input_checks = { path = "../input_checks" }

A path source has no version history of its own. Its content is whatever is on disk at that moment, so it cannot be reproduced on another machine unless the same directory exists there.

3.3 Git sources

A Git source names a repository URL and a reference. The reference can be a branch, a tag, or a commit.

[dependencies]
input_checks = { git = "https://example.com/team/input_checks.git", tag = "v1.2.0" }
test_helpers = { git = "https://example.com/team/test_helpers.git", rev = "9f3c2ab" }

A branch moves every time someone pushes. A tag should not move but can be rewritten. A full commit identifier cannot change, so it is the strongest Git reference.

3.4 Registry sources

A registry source uses a name and a version constraint, as in Lesson 1. The registry resolves the constraint to a published release. Releases are normally immutable once published, and they can carry checksums and signatures, which Lesson 5 covers.

[dependencies]
input_checks = "^1.2.0"

3.5 Comparing the three sources

SourceTypical useReference stabilityPortableIntegrity evidence
Local pathCo-developing a libraryNone: reflects disk stateNoNone
Git, branchFollowing a team branchMoves on every pushYes, if reachableCommit recorded in lock
Git, tagRelease candidatesStable by conventionYes, if reachableCommit recorded in lock
Git, commitStrict pinningImmutableYes, if reachableCommit identifier
RegistryReleased packagesImmutable releasesYesChecksum and signature

3.6 Choosing a source

3.7 Mixing sources in one project

A project can use all three sources at once. Keep the mix deliberate. A common pattern is a path source on a developer branch, replaced by a registry version before merging.

3.8 Mutable and immutable references

A mutable reference can point to different content tomorrow. An immutable reference cannot. Ask of every dependency: if I resolve this again next month, can I get different code?

ReferenceMutable?Risk
PathYesContent changes silently
BranchYesUpstream push changes your build
TagRarelyTag can be moved or deleted
CommitNoLow
Registry releaseNoLow; yanked releases may disappear

3.9 How the lock records sources

The lock from Lesson 2 stores the resolved source for each package. For Git it stores the exact commit, even when the manifest names a branch. For a registry it stores the version and checksum. For a path it stores only the path.

[[package]]
name = "input_checks"
version = "1.2.3"
source = "git+https://example.com/team/input_checks.git#9f3c2ab"

This is why a branch dependency is reproducible only while the lock is kept. Running an update re-resolves the branch to a new commit.

3.10 Portability of path sources

An absolute path such as a home directory fails on every other machine. A relative path works only when the directory layout matches. Treat path sources as a local convenience and keep them out of shared branches.

3.11 Trust and review

3.12 Worked example

The order_rules project needs a fix in input_checks that is not yet published. The team pins a commit while the fix is reviewed.

[dependencies]
input_checks = { git = "https://example.com/team/input_checks.git", rev = "9f3c2ab" }

When version 1.2.4 is published, the team switches back to the registry and removes the Git entry.

[dependencies]
input_checks = "^1.2.4"

3.13 Offline and mirrored environments

Locked builds on restricted networks need the sources to be reachable. Registry mirrors and internal Git hosts keep builds working. Confirm that the mirror serves the same content as the original, using the checksum or commit recorded in the lock.

3.14 Inspecting sources

pea tree
pea lock --check
pea install --locked

Use these illustrative commands to list where each package comes from, confirm the lock matches the manifest, and install exactly what the lock records.

3.15 Source policy for a team

3.16 Common mistakes

MistakeConsequenceFix
Committing a path dependencyBuild fails on other machinesUse a registry or Git source before merging
Depending on a branch without a lockBuilds change without noticeCommit the lock or pin a commit
Trusting a tag as permanentTag is moved and content changesPin the commit
Mixing sources without a reasonHard-to-audit dependency graphDocument each exception

3.17 Guided practice

3.18 Hands-on lab

Take the order_rules project through all three source types and record, for each, the manifest entry, the lock entry, and whether a clean checkout on another machine would reproduce the build.

Deliverable: a one-page table of the three sources with your reproducibility findings.

3.19 Review questions

3.20 Applied challenge

Write a source policy for a team of five that allows path sources locally, requires pinned Git references for unpublished packages, and enforces registry-only dependencies on release branches. Describe how you would check each rule automatically.

Lesson summary

Transition to Lesson 4

Where a package comes from is only part of the picture. Lesson 4 covers permission manifests, archives, installation, and auditing: what a package is allowed to do and how you inspect it.

Lesson status: Ready for review.

← Previous Next →