Skip to main content

install

Function install 

Source
pub fn install(cfg: &Config) -> Result<InstallReport, PkgError>
Expand description

Fetch every dep in the manifest (and their transitive deps), place them, and write the lockfile.

Resolution is a breadth-first worklist seeded with the manifest’s [deps] (sorted by name). Every fetched package that ships its own mlua-pkg.toml appends its [deps] to the worklist, so a consumer declares only what it uses directly. All packages land flat under <vendored>/<name> and in the lockfile, which means one name maps to exactly one spec: a name reached twice with an identical Dep is installed once; reached with different specs the install stops with PkgError::DepConflict naming both requesters. There is no version unification.

Per package:

  1. Pick the package root. With a patch_dir whose lockfile patch_base equals the pinned commit, that directory is the root and nothing is fetched; otherwise fetch via GitFetcher rooted at project.pkg_dir().cache() (a stale / missing patch is reported in warnings and left alone). Prefix tag pins (tag = "v1.0") are resolved inside the fetcher.
  2. Resolve the entry directory: dep.entry > author-manifest entry > src/ > lua/ > . (see resolve_entry).
  3. Place the root: relative symlink at <vendored>/<name> by default, or an idempotent physical copy into <manifest_root>/<target_dir> when target_dir is set (a transitive dep’s target_dir / patch_dir is resolved against the consumer’s manifest, like a direct one). The require root is <root>/<entry>.
  4. Record (name, source, resolved tag, sha, entry, patch_dir, patch_base) for the lockfile; patch_base is carried over from the previous lockfile, never written here.

The lockfile is written once at the end, sorted by name, so a mid-way failure leaves the previous lockfile untouched and the output does not depend on discovery order.

§Errors