---
name: "cargo-module"
section: "5"
platform: "openbsd"
package: "man"
version: "8.0-current-20261101"
release: "OpenBSD 8.0-current (2026-11-01)"
platforms: ["openbsd"]
url: "https://new.carta.tech/cargo-module"
---

# cargo-module(5)

devel/cargo port module

## NAME

**cargo-module** – devel/cargo port module

## DESCRIPTION

This manual page documents the behavior of setting MODULES=devel/cargo in the [ports(7)](/ports/7.md) tree.

Automates download and compilation of dependencies of a Rust project using [cargo(1)](/cargo/1.md).

During **fetch**, static dependencies ("crates") listed in MODCARGO\_CRATES are downloaded using MODCARGO\_DIST\_SUBDIR as DIST\_SUBDIR.

During **post-extract**, crates defined in MODCARGO\_CRATES are moved to the MODCARGO\_VENDOR\_DIR directory. If MODCARGO\_CRATES\_BUILDDEP is enabled, the module may modify vendored crates in order to prefer system libraries instead of bundled upstream copies. This affects several common “-sys” crates such as “openssl-sys” and “libsqlite3-sys”.

During **post-patch**, crate-metadata are generated using *devel/cargo-generate-vendor*.

With CONFIGURE\_STYLE set to ‘cargo’, cargo is configured to use MODCARGO\_VENDOR\_DIR instead of the standard crates-io network source. Finally, any crates listed in MODCARGO\_CRATES\_UPDATE are updated.

MODCARGO\_RUSTFLAGS can be used to pass custom flags to all [rustc(1)](/rustc/1.md) invocations.

*lang/rust* is added to MODULES, and *devel/cargo-generate-vendor* is added to BUILD\_DEPENDS.

This module defines:

- MODCARGO\_BUILD

  Whether to define the default **do-build** target. Defaults to ‘Yes’.

- MODCARGO\_BUILD\_ARGS

  Additional arguments passed to **cargo** **build**.

- MODCARGO\_CARGOTOML

  Path to cargo manifest. Defaults to *${WRKSRC}/Cargo.toml*.

- MODCARGO\_CARGOLOCK

  Path to *Cargo.lock*, which is used only by the **modcargo-gen-crates** target. Defaults to *${MODCARGO\_CARGOTOML:toml=lock}*.

- MODCARGO\_CRATES

  Crates that will be downloaded by the module.

- MODCARGO\_CRATES\_BUILDDEP

  Whether to modify vendored crates in order to prefer system libraries over bundled upstream sources. Defaults to ‘Yes’.

- MODCARGO\_CRATES\_KEEP

  List of crates that should not be modified during **post-extract**. Entries may be specified either as crate names or “name-version”.

- MODCARGO\_CRATES\_UPDATE

  List of crates to update, overriding the version listed in Cargo.lock.

- MODCARGO\_DIST\_SUBDIR

  Subdirectory used for crate distfiles. Defaults to ‘cargo’. If DIST\_SUBDIR is defined, MODCARGO\_DIST\_SUBDIR must also be defined.

- MODCARGO\_FEATURES

  List of features to be used when building.

- MODCARGO\_INSTALL

  Whether to define the default **do-install** target. Defaults to ‘Yes’.

- MODCARGO\_INSTALL\_ARGS

  Additional arguments passed to **cargo** **install**.

- MODCARGO\_INSTALL\_TARGET\_PATHS

  List of paths to pass to **cargo** **install** instead of *.*. Needs to be set for some virtual manifests.

- MODCARGO\_NO\_DEFAULT\_FEATURES

  If set to ‘Yes’, pass **--no-default-features** to cargo commands.

- MODCARGO\_RUSTFLAGS

  Flags passed to all [rustc(1)](/rustc/1.md) invocations performed by [cargo(1)](/cargo/1.md).

- MODCARGO\_TARGET\_DIR

  Location of cargo build artifacts. Defaults to *${WRKBUILD}/target*.

- MODCARGO\_TEST

  Whether to define the default **do-test** target. Defaults to ‘Yes’.

- MODCARGO\_TEST\_ARGS

  Additional arguments passed to

- MODCARGO\_LIBTEST\_ARGS

  Additional arguments passed to libtest. **cargo** **test**.

- MODCARGO\_CARGO\_BIN

  Path to the [cargo(1)](/cargo/1.md) binary. Defaults to the version provided by *devel/cargo*.

- MODCARGO\_VENDOR\_DIR

  Name of the local directory for vendoring crates. Defaults to *${WRKSRC}/modcargo-crates*.

- MODCARGO\_WANTLIB

  Architecture-specific WANTLIB entries required by all Rust code. It is a copy of MODRUST\_WANTLIB provided for simplicity.

The module creates a local cargo configuration in *${WRKDIR}/.cargo/config.toml* which configures vendored sources, offline operation, Rust toolchain paths, and build profiles.

This module adds three [make(1)](/make/1.md) targets:

- **modcargo-metadata**

  Rerun the generation of crates' metadata.

- **modcargo-gen-crates**

  Generate the MODCARGO\_CRATES list from Cargo.lock (a preliminary crates list is not required).

- **modcargo-gen-crates-licenses**

  Generate the MODCARGO\_CRATES list with license information from crates present in the MODCARGO\_VENDOR\_DIR directory.

## SEE ALSO

[port-modules(5)](/port-modules/5.md)
