Skip to content
Skills Library
Programming · Learning & explanation

koopa-rust

/koopa-rust

Rust and cargo conventions for koopa installers, hermetic CARGO_HOME, build dependency wiring, and the NO_RUST opt-out pattern. Use when writing or debugging any installer that builds with cargo, whether directly (rust-package installers) or indirectly (build tools like git that shell out to cargo from their own Makefile).

Repository
koopa ↗
Licence
Apache-2.0
Last repository change
26.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 26.10.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

Rust and cargo conventions for koopa installers, hermetic CARGO_HOME, build dependency wiring, and the NO_RUST opt-out pattern. Use when writing or debugging any installer that builds with cargo, whether directly (rust-package installers) or indirectly (build tools like git that shell out to cargo from their own Makefile).

Original author description

Rust and cargo conventions for koopa installers, hermetic CARGO_HOME, build dependency wiring, and the NO_RUST opt-out pattern. Use when writing or debugging any installer that builds with cargo, whether directly (rust-package installers) or indirectly (build tools like git that shell out to cargo from their own Makefile).

How it works

  1. Hermetic CARGOHOME (required for all koopa cargo builds)
  2. Declaring rust as a build dependency
  3. NORUST opt-out
  4. Offline / self-contained crates
Original SKILL.md headings · 72 lines, 377 words
SKILL.md preview
---
name: koopa-rust
description: >-
  Rust and cargo conventions for koopa installers, hermetic CARGO_HOME, build
  dependency wiring, and the NO_RUST opt-out pattern. Use when writing or debugging
  any installer that builds with cargo, whether directly (rust-package installers) or
  indirectly (build tools like git that shell out to cargo from their own Makefile).
---

# koopa Rust / Cargo Conventions

## Hermetic `CARGO_HOME` (required for all koopa cargo builds)

**Always point `CARGO_HOME` at a temp dir.** Never let cargo read from or write to
`~/.cargo` during an installer build; that leaks toolchain state across builds and
can corrupt the user's personal cargo registry.

```python
import tempfile

subprocess_env = env.to_env_dict()
subprocess_env["CARGO_HOME"] = tempfile.mkdtemp(prefix="koopa-cargo-")
```

`subprocess_env` is then passed to every `subprocess.run(...)` call for the build.
This applies whether:

- koopa is **directly** invoking `cargo install` (the `_rust_pkg.py` / `install_rust_package`
  path in `install.py:1313`), or
- koopa is invoking another build tool (`make`, `cmake`, …) that **itself** shells out
  to `cargo` (e.g. git ≥ 2.50, which runs `cargo build target/release/libgitcore.a`).

Existing examples using this pattern:
- `lang/python/src/koopa/installers/rust_app.py`: sets `CARGO_HOME` in the rustup
  install env.
- `lang/python/src/koopa/install.py:1313` (`install_rust_package`): uses
  `tempfile.mkdtemp(prefix="koopa-cargo-")`.
- `lang/python/src/koopa/installers/git_app.py`: sets `CARGO_HOME` on `subprocess_env`
  before the `make` build so git's internal cargo call is hermetic.

## Declaring `rust` as a build dependency

Any installer that needs `cargo` must list `"rust"` in the app's
`build_dependencies` in `etc/koopa/app.json`. This:

1. Installs `rust` before the current app (if not already present).
2. Prepends `opt/rust/bin` to the build PATH via `activate_app_deps()` →
   `activate_app(..., build_only=True)` in `_build_helper.py`, so `cargo` (and
   `rustc`, `clippy`, etc.) resolve inside `make`/`cmake`/any subprocess.

```json
"build_dependencies": [
  "...",
  "rust",
  "..."
]
```

`rust` has `"default": false` in the registry: that is intentional and correct (it
is a large optional toolchain). Listing it in `build_dependencies` still causes it to
be installed before the dependent app regardless of `default`.

## `NO_RUST` opt-out

If an app's build system provides a Makefile variable to disable its Rust path
(e.g. `NO_RUST=1` for git ≥ 2.50), do **not** use it in koopa installers. The goal
is to enable Rust features, not suppress them. Reserve `NO_RUST` only for emergency
fallback builds when the `rust` app is unavailable.

## Offline / self-contained crates

Before wiring `cargo` into a new installer, check the upstream `Cargo.toml` for
external dependencies. If `[dependencies]` is empty (as it is for git 2.55.0), the
cargo build is fully offline and requires no special network flags or vendoring.

If there are `[dependencies]`, the build needs network access or a vendored tarball —
handle the same way as `install_rust_package` (see `install.py`), setting
`CARGO_NET_GIT_FETCH_WITH_CLI=true` and pre-downloading crates if offline builds
are required.

Versions

The database has no other skills named koopa-rust.

Database snapshot: 13.11.2026 · package version 7b25a8e0000d (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90cargo-workflows
    Use when managing Cargo workspaces, feature flags, build scripts, CI caching, dependency auditing, or Cargo.lock with Rust.
  • 90cargo-workflows
    Use when managing Cargo workspaces, feature flags, build scripts, CI caching, dependency auditing, or Cargo.lock with Rust.
  • 100claude-skill-rust
    Guide for Rust development including code style, testing, building, and quality checks using cargo tools. Apply when working with Rust code, Cargo.toml, or running cargo commands.
  • 90rust
    This skill should be used when writing or reviewing Rust code, or when the project uses "Rust", "Cargo", "cargo clippy", "crate", or Rust module patterns. Provides Rust coding conventions, patterns, and best practices. Project-specific conventions always take priority.
  • 100cargo-test
    Expert Cargo test assistance covering Rust unit tests, integration tests, and benchmarks. Use when running `cargo test`, writing unit tests in Rust, or debugging test failures.
  • 90cc-rust-project-standard
    Use when Rust crate or workspace structure, module boundaries, ownership-facing APIs, Result conventions, Cargo dependencies or engineering checks need design or review.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.