Skip to content

fix(hiroz-msgs): allow publishing to crates.io - #332

Merged
YuanYuYuan merged 5 commits into
mainfrom
feat/publish-hiroz-msgs
Aug 31, 2026
Merged

YuanYuYuan merged 5 commits into
mainfrom
feat/publish-hiroz-msgs

Conversation

@YuanYuYuan

Copy link
Copy Markdown
Collaborator

Summary

hiroz-msgs's build.rs located .msg/.srv codegen assets via a sibling-directory path (manifest_dir.parent().join("hiroz-codegen/assets")), which only exists inside this workspace's checkout layout. cargo package/cargo publish only bundle files inside a crate's own root, so hiroz-codegen/assets — a sibling directory — would never exist in the packaged tarball, and hiroz-msgs could never be published to crates.io. This PR removes that blocker.

It also unblocks anyone building their own message-package crate on top of hiroz-msgs (see the my-robot-msgs example in docs/user-guide/custom-messages.md): crates.io refuses to publish any crate with a git dependency, and hiroz-msgs was git-only.

Before and after

before after
asset resolution manifest_dir.parent().join("hiroz-codegen/assets") — sibling path, workspace-checkout-only hiroz_codegen::bundled_assets_dir(is_humble) — resolves via hiroz-codegen's own (published) CARGO_MANIFEST_DIR
hiroz-msgs/Cargo.toml publish = false, no crates.io metadata publishable, metadata matches hiroz/hiroz-codegen's style, hiroz/hiroz-derive path deps pinned to version = "0.2"
docs/user-guide/custom-messages.md example hiroz-msgs = { git = "https://github.com/ZettaScaleLabs/hiroz.git" } hiroz-msgs = { version = "0.2" }
cargo package -p hiroz-msgs --list not attempted 26 files, all under the crate's own root
cargo publish -p hiroz-msgs --dry-run fails (needs the sibling dir) succeeds

What fails without this

cargo publish -p hiroz-msgs --dry-run cannot succeed today — the packaged crate is missing hiroz-codegen/assets, so anyone building it outside the workspace checkout hits a missing-directory error at build time.

Verified on a clean checkout at this commit: cargo build -p hiroz-msgs --features core_msgs and other in-workspace feature combinations still build unchanged; cargo package -p hiroz-msgs --list shows nothing outside the crate root; cargo publish -p hiroz-msgs --dry-run packages successfully. As a further check, downloading the already-published hiroz/hiroz-codegen v0.2.0 from crates.io and rebuilding hiroz-msgs standalone against them (outside the workspace) confirmed codegen runs correctly against the crates.io-downloaded bundled assets.

Breaking changes

None. The ROS 2 installation / HIROZ_MSG_PATH fallback path in build.rs is unchanged; only the local-bundled-assets source changed from a sibling path to the hiroz-codegen public API.

Known follow-up

hiroz/hiroz-derive's path dependencies in hiroz-msgs/Cargo.toml now carry a hardcoded version = "0.2" (required for cargo publish to accept a path dependency). It does not derive from version.workspace, so it needs a manual bump alongside future workspace version bumps, or it will silently pin a stale minimum version in the published manifest while local/path builds keep working unaffected.

build.rs reached outside its own crate directory to find hiroz-codegen's
.msg/.srv assets, which cargo package/publish cannot bundle. Use
hiroz_codegen::bundled_assets_dir instead, which resolves against
hiroz-codegen's own CARGO_MANIFEST_DIR and works whether hiroz-codegen
is a path or crates.io dependency.

Also add the crates.io metadata hiroz/hiroz-codegen already carry, pin
versions on the path dependencies cargo publish requires, and remove
publish = false so hiroz-msgs can be published. Update the
custom-messages doc example to use version dependencies instead of git.
@github-actions

github-actions Bot commented Aug 30, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-08-31 11:29 UTC

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Makes hiroz-msgs publishable by resolving bundled code-generation assets through hiroz-codegen.

Changes:

  • Adds crates.io metadata and versioned dependencies.
  • Updates bundled asset discovery.
  • Documents crates.io dependencies for custom messages.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/hiroz-msgs/Cargo.toml Enables crates.io publication.
crates/hiroz-msgs/build.rs Resolves assets through hiroz-codegen.
docs/user-guide/custom-messages.md Updates dependency examples.
Suppressed comments (1)

crates/hiroz-msgs/build.rs:431

  • bundled_assets_dir(true) resolves to hiroz-codegen/assets/humble, but this repository/package contains only assets/jazzy. Consequently a Humble build without a system ROS installation finds no bundled packages and never generates generated.rs, whereas the previous code always used the Jazzy asset corpus. Keep selecting the Jazzy corpus here (the package list already excludes post-Humble interfaces), or add and publish a complete Humble corpus.
    let assets_dir = hiroz_codegen::bundled_assets_dir(is_humble);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/hiroz-msgs/build.rs Outdated
Passing is_humble to bundled_assets_dir resolved to assets/humble,
which hiroz-codegen ships empty (only assets/jazzy is populated).
A Humble build with no system ROS install would silently find zero
bundled packages instead of falling back to the jazzy corpus, same
as before this branch.
check-bundled-msgs runs in the pureRust devshell, which has no system
ROS install, so it's the one place a broken bundled-assets fallback
can't be masked by discover_ros_packages' system-install fallback the
way every ROS-container job masks it. Add the missing cell: hiroz-msgs
built with --features humble and no ROS sourced.

Verified both directions on this commit's parent: reverting the
bundled_assets_dir(false) fix and running this check fails to compile
(missing generated.rs, ros_packages len: 0); restoring the fix makes
it pass (ros_packages len: 11).
…comments in STE

hiroz-derive is already declared in [workspace.dependencies], so use
workspace = true instead of a second hardcoded version literal —
one fewer place for the version pin to drift.

hiroz itself can't take the same treatment: Cargo does not currently
support overriding default-features on a workspace = true dependency
(a known Cargo limitation), and hiroz-msgs needs
default-features = false, features = ["rmw-zenoh"]. It keeps its
explicit path + version form.

Also rewrote this branch's own added comments in build.rs and
scripts/test-pure-rust.nu to Simplified Technical English.
@YuanYuYuan
YuanYuYuan merged commit 6f59556 into main Aug 31, 2026
33 checks passed
@YuanYuYuan
YuanYuYuan deleted the feat/publish-hiroz-msgs branch August 31, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants