Skip to main content

resolve_entry

Function resolve_entry 

Source
pub fn resolve_entry(
    cache_path: &Path,
    override_entry: Option<&Path>,
) -> Result<PathBuf, PkgError>
Expand description

Resolve the Lua require entry point directory for a cached package.

Applies the entry fallback chain in order:

  1. If override_entry is Some(p), check cache_path.join(p) only. If it is not a directory, return PkgError::EntryNotFound immediately (the override is explicit, so fallback would be surprising).
  2. Otherwise, try the default candidates in order:
    • cache_path/src/
    • cache_path/lua/
    • cache_path/ itself (.)

Returns the first candidate that is a directory, or PkgError::EntryNotFound if none exist.

§Notes

This function is used by the install CLI (ST5) to determine the symlink target for each vendored package. resolvers::VendoredResolver itself does not call this function — the lockfile already carries the resolved entry field, and the CLI’s symlink points vendored/<name> at ../cache/…/<sha>/<entry> before the resolver is constructed.

§Errors

Returns PkgError::EntryNotFound when no candidate directory exists.

§Example

use mlua_pkg::resolve_entry;
use std::path::Path;

let entry = resolve_entry(Path::new("/cache/mypkg/abc123"), None)?;
// => /cache/mypkg/abc123/src  (if that directory exists)